#include <Pt/System/LogRecord.h>
Log records can be added to a log. More...
Inherits NonCopyable.
Public Member Functions | |
LogRecord (const LogLevel &level) | |
Construct a log record with a severity level. | |
~LogRecord () | |
@ Destructor. | |
void | clear () |
Clears all content of the record. | |
LogLevel | logLevel () const |
Returns the severity level. | |
template<typename T > | |
LogRecord & | operator<< (const T &value) |
Appends value to the log record's text. | |
LogRecord & | operator<< (std::ostream &(*op)(std::ostream &)) |
Applies op to the log record's text. | |
LogRecord & | operator<< (std::ios &(*op)(std::ios &)) |
Applies op to the log record's text. | |
LogRecord & | operator<< (std::ios_base &(*op)(std::ios_base &)) |
Applies op to the log record's text. | |
LogRecord & | operator<< (const Pt::SourceInfo &si) |
Sets the source location of the log record. | |
const Pt::SourceInfo & | sourceInfo () const |
Returns the location in the source where the record was generated. | |
std::string | text () const |
Returns the textual of the record. | |
Log records represent the text entries that can be added to log. Each log record has a log level, which indicates it's severity. The text of a log record can be formatted with the stream operator, just like writing to std::cout. All stream output operators defined for std::ostream can be used including the manipulators.
Once a log record is created it can be added to a log with a logger. The record might be ignored if the log level is disabled for the logger's target. Unneccessary formatting can be avoided by checking if the record's log level is enabled for the logger's target.
The same log record can be sent multiple times to a logger or to several loggers. This way formatting is only done once and logging performance can be increased.