proxygen
|
#include <LogMessage.h>
Public Member Functions | |
LogMessage (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, std::string &&msg) | |
LogMessage (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, folly::StringPiece msg) | |
LogMessage (const LogCategory *category, LogLevel level, std::chrono::system_clock::time_point timestamp, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, std::string &&msg) | |
const LogCategory * | getCategory () const |
LogLevel | getLevel () const |
folly::StringPiece | getFileName () const |
folly::StringPiece | getFileBaseName () const |
unsigned int | getLineNumber () const |
folly::StringPiece | getFunctionName () const |
std::chrono::system_clock::time_point | getTimestamp () const |
uint64_t | getThreadID () const |
const std::string & | getMessage () const |
const std::string & | getRawMessage () const |
bool | containsNewlines () const |
Private Member Functions | |
void | sanitizeMessage () |
Private Attributes | |
const LogCategory *const | category_ {nullptr} |
LogLevel const | level_ {static_cast<LogLevel>(0)} |
uint64_t const | threadID_ {0} |
std::chrono::system_clock::time_point const | timestamp_ |
folly::StringPiece const | filename_ |
unsigned int const | lineNumber_ {0} |
folly::StringPiece const | functionName_ |
bool | containsNewlines_ {false} |
std::string const | rawMessage_ |
std::string | message_ |
LogMessage represents a single message to be logged.
LogMessage objects are relatively temporary objects, that only exist for the time it takes to invoke all of the appropriate LogHandlers. These generally only live in the thread that logged the message, and are not modified once created. (That said, LogHandler implementations may copy and store LogMessage objects for later use if desired.)
Definition at line 38 of file LogMessage.h.
folly::LogMessage::LogMessage | ( | const LogCategory * | category, |
LogLevel | level, | ||
folly::StringPiece | filename, | ||
unsigned int | lineNumber, | ||
folly::StringPiece | functionName, | ||
std::string && | msg | ||
) |
Definition at line 24 of file LogMessage.cpp.
References category_, filename_, functionName_, folly::getOSThreadID(), level_, lineNumber_, folly::gen::move, now(), rawMessage_, sanitizeMessage(), string, threadID_, and timestamp_.
Referenced by LogMessage().
|
inline |
Definition at line 47 of file LogMessage.h.
References LogMessage(), and string.
folly::LogMessage::LogMessage | ( | const LogCategory * | category, |
LogLevel | level, | ||
std::chrono::system_clock::time_point | timestamp, | ||
folly::StringPiece | filename, | ||
unsigned int | lineNumber, | ||
folly::StringPiece | functionName, | ||
std::string && | msg | ||
) |
Construct a LogMessage with an explicit timestamp. This is primarily intended for use in unit tests, so the tests can get deterministic behavior with regards to timestamps.
|
inline |
Definition at line 117 of file LogMessage.h.
References containsNewlines_, and sanitizeMessage().
Referenced by folly::CustomLogFormatter::formatMessage(), and folly::GlogStyleFormatter::formatMessage().
|
inline |
StringPiece folly::LogMessage::getFileBaseName | ( | ) | const |
Definition at line 61 of file LogMessage.cpp.
References filename_, max, folly::Range< const char * >::npos, folly::Range< Iter >::rfind(), and folly::Range< Iter >::subpiece().
Referenced by folly::CustomLogFormatter::formatMessage(), folly::GlogStyleFormatter::formatMessage(), and getFileName().
|
inline |
Definition at line 84 of file LogMessage.h.
References filename_, and getFileBaseName().
Referenced by folly::LogCategory::admitMessage().
|
inline |
Definition at line 93 of file LogMessage.h.
References functionName_.
Referenced by folly::CustomLogFormatter::formatMessage().
|
inline |
Definition at line 80 of file LogMessage.h.
References level_.
Referenced by folly::LogCategory::admitMessage(), folly::CustomLogFormatter::formatMessage(), folly::GlogStyleFormatter::formatMessage(), and folly::StandardLogHandler::handleMessage().
|
inline |
Definition at line 89 of file LogMessage.h.
References lineNumber_.
Referenced by folly::LogCategory::admitMessage(), folly::CustomLogFormatter::formatMessage(), and folly::GlogStyleFormatter::formatMessage().
|
inline |
Definition at line 105 of file LogMessage.h.
References message_, and rawMessage_.
Referenced by folly::LogCategory::admitMessage(), folly::CustomLogFormatter::formatMessage(), and folly::GlogStyleFormatter::formatMessage().
|
inline |
|
inline |
Definition at line 101 of file LogMessage.h.
References threadID_.
Referenced by folly::CustomLogFormatter::formatMessage(), and folly::GlogStyleFormatter::formatMessage().
|
inline |
Definition at line 97 of file LogMessage.h.
References timestamp_.
Referenced by folly::CustomLogFormatter::formatMessage(), and folly::GlogStyleFormatter::formatMessage().
|
private |
Definition at line 83 of file LogMessage.cpp.
References c, containsNewlines_, folly::data(), message_, and rawMessage_.
Referenced by containsNewlines(), and LogMessage().
|
private |
Definition at line 124 of file LogMessage.h.
Referenced by getCategory(), and LogMessage().
|
private |
containsNewlines_ will be true if the message contains internal newlines.
This allows log handlers that perform special handling of multi-line messages to easily detect if a message contains multiple lines or not.
Definition at line 150 of file LogMessage.h.
Referenced by containsNewlines(), and sanitizeMessage().
|
private |
The name of the source file that generated this log message.
Definition at line 132 of file LogMessage.h.
Referenced by getFileBaseName(), getFileName(), and LogMessage().
|
private |
The name of the function that generated this log message.
Definition at line 142 of file LogMessage.h.
Referenced by getFunctionName(), and LogMessage().
Definition at line 125 of file LogMessage.h.
Referenced by getLevel(), and LogMessage().
|
private |
The line number in the source file that generated this log message.
Definition at line 137 of file LogMessage.h.
Referenced by getLineNumber(), and LogMessage().
|
private |
message_ contains a sanitized version of the log message.
nul bytes and unprintable characters have been escaped. This message may still contain newlines, however. LogHandler classes are responsible for deciding how they want to handle log messages with internal newlines.
Definition at line 168 of file LogMessage.h.
Referenced by getMessage(), and sanitizeMessage().
|
private |
rawMessage_ contains the original message.
This may contain arbitrary binary data, including unprintable characters and nul bytes.
Definition at line 158 of file LogMessage.h.
Referenced by getMessage(), getRawMessage(), LogMessage(), and sanitizeMessage().
|
private |
Definition at line 126 of file LogMessage.h.
Referenced by getThreadID(), and LogMessage().
|
private |
Definition at line 127 of file LogMessage.h.
Referenced by getTimestamp(), and LogMessage().