#include <mcllib/MCLogFile.h>
Inheritance diagram for MCLogFile:
Public Member Functions | |
bool | isOutput (MCMsg::msglevel_t lvl) const |
Test to see if messages at a level will be output. | |
MCLogFile (const MCString &fileName=MCString(0), MCMsg::msglevel_t lvl=MCMsg::MSGLVL_WARN, int maxSize=0, int maxRoll=MAX_ROLL, bool keepOpen=false) | |
Construct a new log file. | |
void | operator() (const MCMsg &msg) |
Output an MCMsg. | |
void | operator() (MCMsg::msglevel_t lvl, const char *fmt,...) |
Output a message at the specified level. | |
void | operator() (const char *fmt,...) |
Output a message at the default level. | |
void | setDefaultLevel (MCMsg::msglevel_t lvl) |
Set the default level. | |
void | setOutputFile (MCFile::EStdHandle hdl) |
Set the output file to a standard file handle. | |
void | setOutputFile (const MCString &fileName) |
Set the output file. | |
void | setOutputLevel (MCMsg::msglevel_t lvl) |
Set the output level. | |
~MCLogFile () | |
Close the log file. | |
Static Public Attributes | |
const int | MAX_ROLL |
Protected Member Functions | |
void | init (const MCString &fileName=MCString(0), MCMsg::msglevel_t lvl=MCMsg::MSGLVL_WARN, int maxSize=0, int maxRoll=MAX_ROLL, bool keepOpen=false) |
Initialize for use in derived classes. | |
void | operator() (MCMsg::msglevel_t lvl, const char *fmt, va_list ap) |
Output a message at the specified level. | |
void | operator() (const char *fmt, va_list ap) |
Output a message at the default level. |
Log files allow messages to be output to them. To prevent disk space exhaustion, log files can have a maximum size specified when they are created. If output of a message causes the maximum size to be exceeded, the log file can be optionally "rolled". When a log file is rolled, the log file is closed and renamed to logfile.1. If logfile.1 exists it will be renamed to logfile.2 before being over-written, this is repeated the number of times specified when the log file was constructed. This mechanism frees the application from the need to worry about log messages exhausting disk space.
The log file has an output level associated with it which is specified at construction but can be changed later. Each message also has an output level associated with it. Only messages with a level less-than or equal to the output level of the log file will be output. All other messages will be silently discarded. This mechanism supports debug and other informational message output in the application that can be enabled or disabled at run-time.
|
Construct a new log file.
|
|
Close the log file. The file is closed if it refers to something other than a standard handle (stderr or stdout). |
|
Initialize for use in derived classes. Arguments are as per the constructor. |
|
Test to see if messages at a level will be output.
|
|
Output a message at the specified level. A new-line is added at the end of the output if one is missing.
|
|
Output a message at the default level. The default level can be set with setDefaultLevel(). A new-line is added at the end of the output if one is missing.
|
|
Output an MCMsg. An MCMsg contains a message level. This is used as the level at which to output the message. A new-line is added at the end of the output if one is missing.
|
|
Output a message at the specified level. A new-line is added at the end of the output if one is missing.
|
|
Output a message at the default level. The default level can be set with setDefaultLevel(). A new-line is added at the end of the output if one is missing.
|
|
Set the default level. The default level is the level which will be used if the operater()(const char*, ...) method is used. The initial default level is the same as the log file output level.
|
|
Set the output file to a standard file handle.
|
|
Set the output file. The existing file (if any) is closed. A message will be printed to stderr if the file cannot be opened. In this case the log is directed to the stderr of the application.
|
|
Set the output level. This is the level at which output messages will be directed to the log file. Attempts to output messages with a level which is higher than this will be ignored.
|