|
LogCabin
|
Namespaces | |
| namespace | Internal |
Classes | |
| struct | DebugMessage |
| When LogCabin wants to print a log message, this is the information that gets included. More... | |
Enumerations | |
| enum | LogLevel { SILENT, ERROR, WARNING, NOTICE, VERBOSE } |
| The levels of verbosity for log messages. More... | |
Functions | |
| std::string | getLogFilename () |
| Return the filename given to the last successful call to setLogFilename(), or the empty string if none. | |
| std::string | setLogFilename (const std::string &filename) |
| Open the given file by name and append future debug log messages to it. | |
| std::string | reopenLogFromFilename () |
| Called to rotate the log file. | |
| FILE * | setLogFile (FILE *newFile) |
| Change the file on which debug log messages are written. | |
| std::function< void(DebugMessage)> | setLogHandler (std::function< void(DebugMessage)> newHandler) |
| Accept log messages on the given callback instead of writing them to a file. | |
| std::vector< std::pair < std::string, std::string > > | getLogPolicy () |
| Return the current log policy (as set by a previous call to setLogPolicy). | |
| void | setLogPolicy (const std::vector< std::pair< std::string, std::string >> &newPolicy) |
| Specify the log messages that should be displayed for each filename. | |
| void | setLogPolicy (const std::initializer_list< std::pair< std::string, std::string >> &newPolicy) |
| See setLogPolicy. | |
| std::vector< std::pair < std::string, std::string > > | logPolicyFromString (const std::string &in) |
| Build a log policy from its string representation. | |
| std::string | logPolicyToString (const std::vector< std::pair< std::string, std::string >> &policy) |
| Serialize a log policy into a string representation. | |
| std::ostream & | operator<< (std::ostream &ostream, LogLevel level) |
| Output a LogLevel to a stream. | |
| bool | isLogging (LogLevel level, const char *fileName) |
| Return whether the current logging configuration includes messages of the given level for the given filename. | |
| void | log (LogLevel level, const char *fileName, uint32_t lineNum, const char *functionName, const char *message) |
| Unconditionally log the given message to stderr. | |
Variables | |
| std::string | processName |
| A short name to be used in log messages to identify this process. | |
The levels of verbosity for log messages.
Higher values are noisier.
| std::string LogCabin::Core::Debug::getLogFilename | ( | ) |
Return the filename given to the last successful call to setLogFilename(), or the empty string if none.
| std::string LogCabin::Core::Debug::setLogFilename | ( | const std::string & | filename | ) |
Open the given file by name and append future debug log messages to it.
Note that if a handler is set with setLogHandler, this file will not be used.
| filename | Name of file. If it already exists, new messages will be appended at the end. If the file is already open, this will re-open it (useful for rotating logs). |
| std::string LogCabin::Core::Debug::reopenLogFromFilename | ( | ) |
Called to rotate the log file.
If there was a previous call to setLogFilename(), this will reopen that file by name, returning any errors. Otherwise, it will do nothing.
| FILE * LogCabin::Core::Debug::setLogFile | ( | FILE * | newFile | ) |
Change the file on which debug log messages are written.
Note that if a handler is set with setLogHandler, this file will not be used. If a filename has been set with setLogFilename(), this will clear it.
| newFile | Handle to open file where log messages will be written. |
| std::function< void(DebugMessage)> LogCabin::Core::Debug::setLogHandler | ( | std::function< void(DebugMessage)> | newHandler | ) |
Accept log messages on the given callback instead of writing them to a file.
Call this again with an empty std::function() to clear it.
| newHandler | Callback invoked once per log message, possibly concurrently. |
| std::vector< std::pair< std::string, std::string > > LogCabin::Core::Debug::getLogPolicy | ( | ) |
| void LogCabin::Core::Debug::setLogPolicy | ( | const std::vector< std::pair< std::string, std::string >> & | newPolicy | ) |
Specify the log messages that should be displayed for each filename.
This first component is a pattern; the second is a log level. A filename is matched against each pattern in order: if the filename starts with or ends with the pattern, the corresponding log level defines the most verbose messages that are to be displayed for the file. If a filename matches no pattern, its log level will default to NOTICE.
| void LogCabin::Core::Debug::setLogPolicy | ( | const std::initializer_list< std::pair< std::string, std::string >> & | newPolicy | ) |
| std::vector< std::pair< std::string, std::string > > LogCabin::Core::Debug::logPolicyFromString | ( | const std::string & | in | ) |
Build a log policy from its string representation.
| in | A string of the form "pattern@level,pattern@level,level". The pattern is separated from the level by an at symbol. Multiple rules are separated by comma. A rule with an empty pattern (match all) does not need an at symbol. |
| std::string LogCabin::Core::Debug::logPolicyToString | ( | const std::vector< std::pair< std::string, std::string >> & | policy | ) |
| std::ostream & LogCabin::Core::Debug::operator<< | ( | std::ostream & | ostream, |
| LogLevel | level | ||
| ) |
| bool LogCabin::Core::Debug::isLogging | ( | LogLevel | level, |
| const char * | fileName | ||
| ) |
Return whether the current logging configuration includes messages of the given level for the given filename.
This is normally called by LOG().
| level | The log level to query. |
| fileName | This should be a string literal, probably __FILE__, since the result of this call will be cached based on the memory address pointed to by 'fileName'. |
| void LogCabin::Core::Debug::log | ( | LogLevel | level, |
| const char * | fileName, | ||
| uint32_t | lineNum, | ||
| const char * | functionName, | ||
| const char * | message | ||
| ) |
Unconditionally log the given message to stderr.
This is normally called by LOG().
| level | The level of importance of the message. |
| fileName | The output of __FILE__. |
| lineNum | The output of __LINE__. |
| functionName | The output of __FUNCTION__. |
| message | A descriptive message to print, which should not include a line break at the end. |
| std::string LogCabin::Core::Debug::processName |
1.7.6.1