#include <FileLogger.h++>


Public Member Functions | |
| FileLogger (const String &format="[%d %t] %m", size_t maxLogSize=2048, uint_t rotateCount=1) | |
| Construct a new FileLogger with the given log message format and logging characteristics. | |
| virtual | ~FileLogger () |
| Destructor. | |
| virtual bool | setFile (const String &dir, const String &name) |
| Set the logging directory and log file name. | |
| void | setMaxLogSize (size_t maxLogSize) |
| Set the maximum size for log files. | |
| void | setRotateCount (uint_t rotateCount) |
| Set the rotation log file count. | |
| void | setFormat (const String &format) |
| Set the log message format. | |
| void | log (LogLevel level, const char *file, int line, const char *message,...) |
| Log a message. | |
| void | vlog (LogLevel level, const char *file, int line, const char *message, va_list args) |
| Log a message. | |
| void | enableLogLevel (LogLevel level) |
| Enable a specific log level. | |
| void | disableLogLevel (LogLevel level) |
| Disable a specific log level. | |
| bool | isLogLevelEnabled (LogLevel level) const |
| Test if a specific log level is enabled. | |
| LogFormat & | getLogFormat () |
| Get the LogFormat used by this Logger. | |
Static Public Attributes | |
| static const uint_t | MAX_ROTATE_COUNT = 9 |
| The maximum file rotate count. | |
| static const size_t | LOG_BUFFER_SIZE = 1024 |
| The log buffer size. | |
Protected Member Functions | |
| virtual void | openFile () throw (IOException) |
| Open the log file. | |
| virtual bool | write (CharBuffer &buffer) |
| Write a preformatted log message to the file. | |
| bool | _rotate () |
Protected Attributes | |
| int64_t | _maxFileSize |
| size_t | _maxLogSize |
| size_t | _curLogSize |
| uint_t | _rotateCount |
| File * | _file |
| String | _dir |
| String | _name |
| FileLogger | ( | const String & | format = "[%d %t] %m", |
|
| size_t | maxLogSize = 2048, |
|||
| uint_t | rotateCount = 1 | |||
| ) |
Construct a new FileLogger with the given log message format and logging characteristics.
| format | The log message format. | |
| maxLogSize | The maximum log file size, in kilobytes. | |
| rotateCount | The maximum number of backlog files to create. The value must range from 0 to 9, with 0 indicating that log rotation is disabled. |
| ~FileLogger | ( | ) | [virtual] |
Destructor.
| bool _rotate | ( | ) | [protected] |
| void disableLogLevel | ( | LogLevel | level | ) | [inherited] |
Disable a specific log level.
| level | The level to disable. |
| void enableLogLevel | ( | LogLevel | level | ) | [inherited] |
Enable a specific log level.
| level | The level to enable. |
| bool isLogLevelEnabled | ( | LogLevel | level | ) | const [inherited] |
Test if a specific log level is enabled.
| void log | ( | LogLevel | level, | |
| const char * | file, | |||
| int | line, | |||
| const char * | message, | |||
| ... | ||||
| ) | [inherited] |
Log a message.
| level | The log level (severity). | |
| file | The source filename. | |
| line | The source file line number. | |
| message | The log message. | |
| ... | Optional message arguments. |
| void openFile | ( | ) | throw (IOException) [protected, virtual] |
Open the log file.
Set the logging directory and log file name.
| dir | The directory in which log files will be created. | |
| name | The base name for the log file; log files will be named name.log, name.1.log, etc.. |
| void setFormat | ( | const String & | format | ) | [inherited] |
Set the log message format.
| format | The log message format. |
| void setMaxLogSize | ( | size_t | maxLogSize | ) |
Set the maximum size for log files.
| maxLogSize | The maximum log file size, in kilobytes. |
| void setRotateCount | ( | uint_t | rotateCount | ) |
Set the rotation log file count.
| rotateCount | The maximum number of backlog files to create. The value must range from 0 to 9, with 0 indicating that log rotation is disabled. |
| void vlog | ( | LogLevel | level, | |
| const char * | file, | |||
| int | line, | |||
| const char * | message, | |||
| va_list | args | |||
| ) | [inherited] |
Log a message.
| level | The log level (severity). | |
| file | The source filename. | |
| line | The source file line number. | |
| message | The log message. | |
| args | Optional message arguments. |
| bool write | ( | CharBuffer & | buffer | ) | [protected, virtual] |
size_t _curLogSize [protected] |
int64_t _maxFileSize [protected] |
size_t _maxLogSize [protected] |
uint_t _rotateCount [protected] |
const size_t LOG_BUFFER_SIZE = 1024 [static, inherited] |
The log buffer size.
Indicates the maximum length of a log message, in characters. Messages which exceed this length will be truncated.
const uint_t MAX_ROTATE_COUNT = 9 [static] |
The maximum file rotate count.
1.5.9