libcommonc++
0.7
|
A log message formatter. More...
#include <LogFormat.h++>
Public Member Functions | |
LogFormat (String format="[%D %T] %F:%L %m") | |
Construct a new LogFormat. More... | |
virtual | ~LogFormat () |
Destructor. More... | |
void | setFormat (const String &format) |
Set the log message format. More... | |
void | format (CharBuffer &buffer, LogLevel level, const char *file, int line, const char *message, va_list args) |
Format a log message and write it to a buffer. More... | |
void | setShortDateFormat (const String &format) |
Set the short format for dates. More... | |
void | setLongDateFormat (const String &format) |
Set the long format for dates. More... | |
void | setShortTimeFormat (const String &format) |
Set the short format for times. More... | |
void | setLongTimeFormat (const String &format) |
Set the long format for times. More... | |
A log message formatter.
A format string specifies the format for log messages; it may contain format directives which allow various bits of information to be inserted into the message, and which affect the appearance of the message itself, such as font and color. The following table describes all of the available format directives.
Directive | Meaning |
---|---|
%T | The current time, in long format. |
%t | The current time, in short format. |
%D | The current date, in long format. |
%d | The current date, in short format. |
%F | The filename of the current source file. |
%L | The line number in the current source file. |
%m | The log message proper. |
%h | The ID of the calling thread. |
%p | The process ID. |
%o | The name of the host operating system. |
%a | The architecture of the host system. |
%v | The version number of the host operating system. |
%u | The username of the current user. |
%H | The hostname. |
%A | The application name. |
%l | The log level; one of the characters D, I, W, E. |
%% | A literal % character. |
%* | Begin bold text. |
%_ | Begin underlined text. |
%# | Begin inverse text. |
%- | Begin plain text (all other attributes off). |
%0 | Change text foreground color to default. |
%1 | Change text foreground color to black. |
%2 | Change text foreground color to red. |
%3 | Change text foreground color to green. |
%4 | Change text foreground color to yellow. |
%5 | Change text foreground color to blue. |
%6 | Change text foreground color to magenta. |
%7 | Change text foreground color to cyan. |
%8 | Change text foreground color to white. |
%. | Turn all text styles off. |
%@ | Turn on text autocolor. |
%n | A newline character. |
Construct a new LogFormat.
format | The log message format. |
|
virtual |
Destructor.
void format | ( | CharBuffer & | buffer, |
LogLevel | level, | ||
const char * | file, | ||
int | line, | ||
const char * | message, | ||
va_list | args | ||
) |
Format a log message and write it to a buffer.
This method is not meant to be used directly; it is called transparently by the Log class when one of the logging macros is used.
buffer | The output buffer for the resulting message. |
level | The logging (severity) level for the message. |
file | The source file of the originating log statement. |
line | The source line of the originating log statement. |
message | The formatted message. |
args | Optional message arguments. |
void setFormat | ( | const String & | format | ) |
Set the log message format.
void setLongDateFormat | ( | const String & | format | ) |
Set the long format for dates.
See DateTimeFormat.
void setLongTimeFormat | ( | const String & | format | ) |
Set the long format for times.
See DateTimeFormat.
void setShortDateFormat | ( | const String & | format | ) |
Set the short format for dates.
See DateTimeFormat.
void setShortTimeFormat | ( | const String & | format | ) |
Set the short format for times.
See DateTimeFormat.