proxygen
|
#include <LogStreamProcessor.h>
Public Types | |
enum | AppendType { APPEND } |
enum | FormatType { FORMAT } |
Public Member Functions | |
LogStreamProcessor (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, AppendType) noexcept | |
template<typename... Args> | |
LogStreamProcessor (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, AppendType, Args &&...args) noexcept | |
template<typename... Args> | |
LogStreamProcessor (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, FormatType, folly::StringPiece fmt, Args &&...args) noexcept | |
LogStreamProcessor (XlogCategoryInfo< true > *categoryInfo, LogLevel level, folly::StringPiece categoryName, bool isCategoryNameOverridden, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, AppendType) noexcept | |
template<typename... Args> | |
LogStreamProcessor (XlogCategoryInfo< true > *categoryInfo, LogLevel level, folly::StringPiece categoryName, bool isCategoryNameOverridden, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, AppendType, Args &&...args) noexcept | |
template<typename... Args> | |
LogStreamProcessor (XlogCategoryInfo< true > *categoryInfo, LogLevel level, folly::StringPiece categoryName, bool isCategoryNameOverridden, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, FormatType, folly::StringPiece fmt, Args &&...args) noexcept | |
~LogStreamProcessor () noexcept | |
void | operator& (std::ostream &stream) noexcept |
void | operator& (LogStream &&stream) noexcept |
std::ostream & | stream () noexcept |
void | logNow () noexcept |
Private Types | |
enum | InternalType { INTERNAL } |
Private Member Functions | |
LogStreamProcessor (const LogCategory *category, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, InternalType, std::string &&msg) noexcept | |
LogStreamProcessor (XlogCategoryInfo< true > *categoryInfo, LogLevel level, folly::StringPiece categoryName, bool isCategoryNameOverridden, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, InternalType, std::string &&msg) noexcept | |
LogStreamProcessor (XlogFileScopeInfo *fileScopeInfo, LogLevel level, folly::StringPiece filename, unsigned int lineNumber, folly::StringPiece functionName, InternalType, std::string &&msg) noexcept | |
std::string | extractMessageString (LogStream &stream) noexcept |
template<typename... Args> | |
FOLLY_NOINLINE std::string | createLogString (Args &&...args) noexcept |
template<typename... Args> | |
FOLLY_NOINLINE std::string | formatLogString (folly::StringPiece fmt, const Args &...args) noexcept |
template<typename Arg1 , typename... Args> | |
void | fallbackFormat (std::string *str, const Arg1 &arg1, const Args &...remainder) |
template<typename Arg > | |
void | fallbackFormat (std::string *str, const Arg &arg) |
Private Attributes | |
const LogCategory *const | category_ |
LogLevel const | level_ |
folly::StringPiece | filename_ |
unsigned int | lineNumber_ |
folly::StringPiece | functionName_ |
std::string | message_ |
LogStream | stream_ |
LogStreamProcessor receives a LogStream and logs it.
This class is primarily intended to be used through the FB_LOG*() macros. Its API is designed to support these macros, and is not designed for other use.
The operator&() method is used to trigger the logging. This operator is used because it has lower precedence than <<, but higher precedence than the ? ternary operator, allowing it to bind with the correct precedence in the log macro implementations.
Definition at line 89 of file LogStreamProcessor.h.
|
private |
|
noexcept |
LogStreamProcessor constructor for use with a LOG() macro with no extra arguments.
Note that the filename argument is not copied. The caller should ensure that it points to storage that will remain valid for the lifetime of the LogStreamProcessor. (This is always the case for the FILE preprocessor macro.)
Definition at line 23 of file LogStreamProcessor.cpp.
Referenced by LogStreamProcessor().
|
inlinenoexcept |
LogStreamProcessor constructor for use with a LOG() macro with arguments to be concatenated with folly::to<std::string>()
Note that the filename argument is not copied. The caller should ensure that it points to storage that will remain valid for the lifetime of the LogStreamProcessor. (This is always the case for the FILE preprocessor macro.)
Definition at line 121 of file LogStreamProcessor.h.
References testing::Args().
|
inlinenoexcept |
LogStreamProcessor constructor for use with a LOG() macro with arguments to be concatenated with folly::to<std::string>()
Note that the filename argument is not copied. The caller should ensure that it points to storage that will remain valid for the lifetime of the LogStreamProcessor. (This is always the case for the FILE preprocessor macro.)
Definition at line 148 of file LogStreamProcessor.h.
References testing::Args(), and folly::pushmi::__adl::noexcept().
|
noexcept |
Definition at line 39 of file LogStreamProcessor.cpp.
|
inlinenoexcept |
Definition at line 185 of file LogStreamProcessor.h.
References testing::Args().
|
inlinenoexcept |
Definition at line 206 of file LogStreamProcessor.h.
References testing::Args(), folly::pushmi::__adl::noexcept(), and folly::operator&().
|
noexcept |
|
privatenoexcept |
Definition at line 59 of file LogStreamProcessor.cpp.
References filename_, functionName_, folly::XlogCategoryInfo< IsInHeaderFile >::getCategory(), folly::XlogCategoryInfo< IsInHeaderFile >::init(), folly::XlogCategoryInfo< IsInHeaderFile >::isInitialized(), level_, lineNumber_, message_, folly::gen::move, and stream_.
|
privatenoexcept |
Construct a LogStreamProcessor from an XlogCategoryInfo.
We intentionally define this in LogStreamProcessor.cpp instead of LogStreamProcessor.h to avoid having it inlined at every XLOG() call site, to reduce the emitted code size.
Definition at line 94 of file LogStreamProcessor.cpp.
References category_, filename_, functionName_, INTERNAL, level_, lineNumber_, LogStreamProcessor(), message_, folly::gen::move, folly::pushmi::__adl::noexcept(), stream_, and string.
|
privatenoexcept |
|
inlineprivatenoexcept |
Construct a log message string using folly::to<std::string>()
This function attempts to avoid throwing exceptions. If an error occurs during formatting, a message including the error details is returned instead. This is done to help ensure that log statements do not generate exceptions, but instead just log an error string when something goes wrong.
Definition at line 365 of file LogStreamProcessor.h.
References testing::Args().
|
privatenoexcept |
Definition at line 201 of file LogStreamProcessor.cpp.
References message_, and folly::gen::move.
Referenced by logNow().
|
inlineprivate |
Helper function generate a fallback version of the arguments in case folly::sformat() throws an exception.
This attempts to convert each argument to a string using a similar mechanism to folly::to<std::string>(), if supported.
Definition at line 423 of file LogStreamProcessor.h.
References folly::detail::fallbackFormatOneArg().
|
inlineprivate |
Definition at line 430 of file LogStreamProcessor.h.
References folly::detail::fallbackFormatOneArg().
|
inlineprivatenoexcept |
Construct a log message string using folly::sformat()
This function attempts to avoid throwing exceptions. If an error occurs during formatting, a message including the error details is returned instead. This is done to help ensure that log statements do not generate exceptions, but instead just log an error string when something goes wrong.
Definition at line 390 of file LogStreamProcessor.h.
References testing::Args(), folly::Range< Iter >::data(), folly::sformat(), folly::Range< Iter >::size(), and string.
|
noexcept |
Definition at line 184 of file LogStreamProcessor.cpp.
References folly::LogCategory::admitMessage(), category_, extractMessageString(), filename_, functionName_, level_, lineNumber_, and stream_.
Referenced by folly::LogStreamVoidify< true >::operator&(), and ~LogStreamProcessor().
|
noexcept |
This version of operator&() is typically used when the user specifies log arguments using the << stream operator. The operator<<() generally returns a std::ostream&
|
noexcept |
This version of operator&() is used when no extra arguments are specified with the << operator. In this case the & operator is applied directly to the temporary LogStream object.
|
inlinenoexcept |
Definition at line 319 of file LogStreamProcessor.h.
References folly::pushmi::__adl::noexcept().
Referenced by folly::LogStreamVoidify< true >::operator&().
|
private |
Definition at line 434 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().
|
private |
Definition at line 436 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().
|
private |
Definition at line 438 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().
|
private |
Definition at line 435 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().
|
private |
Definition at line 437 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().
|
private |
Definition at line 439 of file LogStreamProcessor.h.
Referenced by extractMessageString(), and LogStreamProcessor().
|
private |
Definition at line 440 of file LogStreamProcessor.h.
Referenced by logNow(), and LogStreamProcessor().