proxygen
|
#include <TestLogHandler.h>
Public Types | |
using | Options = LogHandlerConfig::Options |
Public Member Functions | |
TestLogHandler () | |
TestLogHandler (LogHandlerConfig config) | |
std::vector< std::pair< LogMessage, const LogCategory * > > & | getMessages () |
std::vector< std::string > | getMessageValues () const |
void | clearMessages () |
void | handleMessage (const LogMessage &message, const LogCategory *handlerCategory) override |
void | flush () override |
uint64_t | getFlushCount () const |
LogHandlerConfig | getConfig () const override |
void | setOptions (const Options &options) |
![]() | |
virtual | ~LogHandler ()=default |
Protected Attributes | |
std::vector< std::pair< LogMessage, const LogCategory * > > | messages_ |
uint64_t | flushCount_ {0} |
std::map< std::string, std::string > | options_ |
LogHandlerConfig | config_ |
A LogHandler that simply keeps a vector of all LogMessages it receives.
This class is not thread-safe. It is intended to be used in single-threaded tests.
Definition at line 36 of file TestLogHandler.h.
Definition at line 38 of file TestLogHandler.h.
|
inline |
Definition at line 40 of file TestLogHandler.h.
|
inlineexplicit |
|
inline |
Definition at line 49 of file TestLogHandler.h.
References messages_.
|
inlineoverridevirtual |
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.
Implements folly::LogHandler.
Definition at line 59 of file TestLogHandler.h.
References flushCount_.
|
inlineoverridevirtual |
Return a LogHandlerConfig object describing the configuration of this LogHandler.
Implements folly::LogHandler.
Definition at line 67 of file TestLogHandler.h.
References config_.
|
inline |
|
inline |
Definition at line 44 of file TestLogHandler.h.
References getMessageValues(), and messages_.
std::vector< std::string > folly::TestLogHandler::getMessageValues | ( | ) | const |
Definition at line 22 of file TestLogHandler.cpp.
References messages_, and values().
Referenced by getMessages().
|
inlineoverridevirtual |
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.
message | The LogMessage objet. |
handlerCategory | The 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. |
Implements folly::LogHandler.
Definition at line 53 of file TestLogHandler.h.
References messages_.
|
inline |
Definition at line 71 of file TestLogHandler.h.
References config_, and folly::LogHandlerConfig::options.
|
protected |
Definition at line 79 of file TestLogHandler.h.
Referenced by getConfig(), and setOptions().
|
protected |
Definition at line 77 of file TestLogHandler.h.
Referenced by flush(), and getFlushCount().
|
protected |
Definition at line 76 of file TestLogHandler.h.
Referenced by clearMessages(), getMessages(), getMessageValues(), and handleMessage().
|
protected |
Definition at line 78 of file TestLogHandler.h.