folly::AsyncFileWriter

An implementation of folly::AsyncLogWriter that writes log messages into a file.

Synopsis

Declared in <folly/logging/AsyncFileWriter.h>

class AsyncFileWriter
    : public AsyncLogWriter

Description

See folly::AsyncLogWriter for details on asynchronous IO.

Base Classes

NameDescription
AsyncLogWriterAn abstract LogWriter implementation that provides functionality for asynchronous IO operations. Users can subclass this class and provide their own IO operation implementation by overriding performIO method. This class will automatically manage incoming log messages and call the method in appropriate time.

Type Aliases

NameDescription
DiscardCallback Callback type invoked with the number of discarded messages.

Enums

NameDescription
Flags Bit flag values for use with writeMessage()

Member Functions

NameDescription
AsyncFileWriter [constructor]Constructors
~AsyncFileWriter [destructor] [virtual]Destroys the writer, flushing any pending output.
flush [virtual]Block until the I/O thread has finished writing all messages that were already enqueued when flush() was called.
getFile Get the output file.
getMaxBufferSize Get the maximum buffer size for this AsyncLogWriter, in bytes.
setMaxBufferSize Set the maximum buffer size for this AsyncLogWriter, in bytes.
ttyOutput [virtual]Returns true if the output steam is a tty.
writeMessage Enqueues a serialized message for asynchronous writing.
writeMessageSync [virtual]Write a message synchronously.

Static Member Functions

NameDescription
setDiscardCallback Set a callback to be invoked when log messages have been discarded.

Static Data Members

NameDescription
kDefaultMaxBufferSize The default maximum buffer size.

Protected Member Functions

NameDescription
cleanup Drain up the log message queue. Subclasses must call this method in their destructors to avoid losing log messages at shutdown.