proxygen
folly::LogHandler Class Referenceabstract

#include <LogHandler.h>

Inheritance diagram for folly::LogHandler:
folly::StandardLogHandler folly::TestLogHandler

Public Member Functions

virtual ~LogHandler ()=default
 
virtual void handleMessage (const LogMessage &message, const LogCategory *handlerCategory)=0
 
virtual void flush ()=0
 
virtual LogHandlerConfig getConfig () const =0
 

Detailed Description

LogHandler represents a generic API for processing log messages.

LogHandlers have an associated log level. The LogHandler will discard any messages below its log level. This allows specific LogHandlers to perform additional filtering of messages even if the messages were enabled at the LogCategory level. For instance, a single LogCategory may have two LogHandlers attached, one that logs locally to a file, and one that sends messages to a remote logging service. The local LogHandler may be configured to record all messages, but the remote LogHandler may want to only process ERROR messages and above, even when debug logging is enabled for this LogCategory.

By default the LogHandler level is set to LogLevel::NONE, which means that all log messages will be processed.

Definition at line 44 of file LogHandler.h.

Constructor & Destructor Documentation

virtual folly::LogHandler::~LogHandler ( )
virtualdefault

Member Function Documentation

virtual void folly::LogHandler::flush ( )
pure virtual

Block until all messages that have already been sent to this LogHandler have been processed.

For LogHandlers that perform asynchronous processing of log messages, this ensures that messages already sent to this handler have finished being processed.

Other threads may still call handleMessage() while flush() is running. handleMessage() calls that did not complete before the flush() call started will not necessarily be processed by the flush call.

Implemented in folly::StandardLogHandler, and folly::TestLogHandler.

virtual LogHandlerConfig folly::LogHandler::getConfig ( ) const
pure virtual

Return a LogHandlerConfig object describing the configuration of this LogHandler.

Implemented in folly::StandardLogHandler, and folly::TestLogHandler.

virtual void folly::LogHandler::handleMessage ( const LogMessage message,
const LogCategory handlerCategory 
)
pure virtual

handleMessage() is called when a log message is processed by a LogCategory that this handler is attached to.

This must be implemented by LogHandler subclasses.

handleMessage() will always be invoked from the thread that logged the message. LogMessage::getThreadID() contains the thread ID, but the LogHandler can also include any other thread-local state they desire, and this will always be data for the thread that originated the log message.

Parameters
messageThe LogMessage objet.
handlerCategoryThe LogCategory that invoked handleMessage(). This is the category that this LogHandler is attached to. Note that this may be different than the category that this message was originally logged at. message->getCategory() returns the category of the log message.

Implemented in folly::StandardLogHandler, and folly::TestLogHandler.


The documentation for this class was generated from the following file: