An 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.
Synopsis
Declared in <folly/logging/AsyncLogWriter.h>
class AsyncLogWriter
: public LogWriter
Description
This class performs the log I/O in a separarate thread.
The advantage of this class over ImmediateFileWriter is that logging I/O can never slow down or block your normal program operation. If log messages are generated faster than they can be written, messages will be dropped (and an indication of how many messages were dropped will be written to the log file when we are able to catch up a bit.)
However, one downside is that if your program crashes, not all log messages may have been written, so you may lose messages generated immediately before the crash.
Base Classes
Name |
Description |
Writes serialized log messages to an output. |
Type Aliases
Name |
Description |
Callback type invoked with the number of discarded messages. |
Enums
Name |
Description |
Bit flag values for use with writeMessage() |
Member Functions
Name |
Description |
|
Constructs the writer and starts its I/O thread. |
|
Stops the I/O thread and destroys the writer. |
|
Block until the I/O thread has finished writing all messages that were already enqueued when flush() was called. |
Get the maximum buffer size for this AsyncLogWriter, in bytes. |
|
Set the maximum buffer size for this AsyncLogWriter, in bytes. |
|
|
Is the log writer writing to a tty or not. |
Enqueues a serialized message for asynchronous writing. |
|
|
Write a message synchronously. |
Static Member Functions
Name |
Description |
Set a callback to be invoked when log messages have been discarded. |
Static Data Members
Name |
Description |
The default maximum buffer size. |
Protected Member Functions
Name |
Description |
Drain up the log message queue. Subclasses must call this method in their destructors to avoid losing log messages at shutdown. |
Derived Classes
Name |
Description |
An implementation of |
Created with MrDocs