FileLogger Class Reference
A logger that writes to a file, and can optionally perform log rotation.
More...
#include <FileLogger.h++>
List of all members.
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.
|
Detailed Description
A logger that writes to a file, and can optionally perform log rotation.
- Author:
- Mark Lindner
Constructor & Destructor Documentation
Construct a new FileLogger with the given log message format and logging characteristics.
- Parameters:
-
| 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. |
Member Function Documentation
| void disableLogLevel |
( |
LogLevel |
level |
) |
[inherited] |
Disable a specific log level.
- Parameters:
-
| level | The level to disable. |
| void enableLogLevel |
( |
LogLevel |
level |
) |
[inherited] |
Enable a specific log level.
- Parameters:
-
| level | The level to enable. |
| LogFormat& getLogFormat |
( |
|
) |
[inline, inherited] |
| 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.
- Parameters:
-
| 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] |
| bool setFile |
( |
const String & |
dir, |
|
|
const String & |
name | |
|
) |
| | [virtual] |
Set the logging directory and log file name.
- Parameters:
-
| 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.
- Parameters:
-
| format | The log message format. |
| void setMaxLogSize |
( |
size_t |
maxLogSize |
) |
|
Set the maximum size for log files.
- Parameters:
-
| maxLogSize | The maximum log file size, in kilobytes. |
| void setRotateCount |
( |
uint_t |
rotateCount |
) |
|
Set the rotation log file count.
- Parameters:
-
| 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.
- Parameters:
-
| 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] |
Write a preformatted log message to the file.
Implements Logger.
Member Data Documentation
The log buffer size.
Indicates the maximum length of a log message, in characters. Messages which exceed this length will be truncated.
The maximum file rotate count.
The documentation for this class was generated from the following files: