A logger that writes to a file, and can optionally perform log rotation.
More...
#include <FileLogger.h++>
|
| 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. More...
|
|
virtual | ~FileLogger () |
| Destructor. More...
|
|
virtual bool | setFile (const String &dir, const String &name) |
| Set the logging directory and log file name. More...
|
|
void | setMaxLogSize (size_t maxLogSize) |
| Set the maximum size for log files. More...
|
|
void | setRotateCount (uint_t rotateCount) |
| Set the rotation log file count. More...
|
|
void | setFormat (const String &format) |
| Set the log message format. More...
|
|
void | log (LogLevel level, const char *file, int line, const char *message,...) |
| Log a message. More...
|
|
void | vlog (LogLevel level, const char *file, int line, const char *message, va_list args) |
| Log a message. More...
|
|
void | enableLogLevel (LogLevel level) |
| Enable a specific log level. More...
|
|
void | disableLogLevel (LogLevel level) |
| Disable a specific log level. More...
|
|
bool | isLogLevelEnabled (LogLevel level) const |
| Test if a specific log level is enabled. More...
|
|
LogFormat & | getLogFormat () |
| Get the LogFormat used by this Logger. More...
|
|
A logger that writes to a file, and can optionally perform log rotation.
- Author
- Mark Lindner
◆ FileLogger()
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. |
◆ ~FileLogger()
◆ disableLogLevel()
Disable a specific log level.
- Parameters
-
level | The level to disable. |
◆ enableLogLevel()
Enable a specific log level.
- Parameters
-
level | The level to enable. |
◆ getLogFormat()
◆ isLogLevelEnabled()
bool isLogLevelEnabled |
( |
LogLevel |
level | ) |
const |
|
inherited |
Test if a specific log level is enabled.
◆ log()
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. |
◆ openFile()
Open the log file.
- Exceptions
-
◆ setFile()
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.. |
◆ setFormat()
void setFormat |
( |
const String & |
format | ) |
|
|
inherited |
Set the log message format.
- Parameters
-
format | The log message format. |
◆ setMaxLogSize()
void setMaxLogSize |
( |
size_t |
maxLogSize | ) |
|
Set the maximum size for log files.
- Parameters
-
maxLogSize | The maximum log file size, in kilobytes. |
◆ setRotateCount()
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. |
◆ vlog()
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. |
◆ write()
Write a preformatted log message to the file.
Implements Logger.
◆ LOG_BUFFER_SIZE
const size_t LOG_BUFFER_SIZE = 1024 |
|
staticinherited |
The log buffer size.
Indicates the maximum length of a log message, in characters. Messages which exceed this length will be truncated.
◆ MAX_ROTATE_COUNT
const uint_t MAX_ROTATE_COUNT = 9 |
|
static |
The maximum file rotate count.
The documentation for this class was generated from the following files: