![]() |
AnCH Framework
0.1
Another C++ Hack Framework
|
AnCH logger library aims to provide facilities for applications logging.
TODO fill this section
The library is used in a similar way that log4j. So the classes which will be used are LoggerFactory to initialize and retrieve logger instances and Logger to log messages.
Messages are logged with level which can be (from the lowest to the highest):
TRACE
DEBUG
INFO
WARN
ERROR
FATAL
Each level has a method in Logger class which is named like level in lower case. These methods take a variable number of arguments which have to have stream injection operator definition.
User can define several writers to log messages in separate files and console. Three writer types are available:
Loggers are defined by category. They are retrieved if the logger name starts with category. Categories are associated with writers and minimum logging level.
AnCH logger library has to be initialized by calling ANCH_LOGGER_INIT
macro.
AnCH logger configuration file is anch-logger.conf
in the execution directory. You can defined another configuration file by defining _ANCH_LOGGER_CONFIG_FILE_
variable.
The file has to defined some writers and loggers (see sections below).
Global configuration variables which can be set are:
low.priority
: use low priority writers which will write messages in other threads. Possible value: 0
or 1
. Default to 0
. The value can be override by writers.thread.safe
: writers are protected against concurrent access. Possible value: 0
or 1
. Default to 1
. The value can be override by writers.Writers are declared in [WRITER::<writer>] section.
[WRITER::console] is a predefined writer which log messages in
std::cout
. The only configuration value for console is writer.pattern
.
Configuration values for writters are:
writer.pattern
: pattern for message formatting. Formatting values:%c
: the category (logger name).%p
: the level.%m
: the message.%t
: the thread identifier.%d{date_format}
: the date (using C++ date formatter).%D{date_format}
: the date (using anch-date formatter with high precision clock).writer.filepath
: log file path.writer.max.size
: the maximum log file size. Optional. Possible value: number + 'K', 'M' or 'G' (for kilobyte, megabyte and gigabyte).writer.max.rotate.index
: the maximum number of file to keep. Optional and active only if writer.max.size
is set.writer.low.priority
: use a low priority writer which will write messages in another thread. Possible value: 0
or 1
. Default to 0
.writer.thread.safe
: writer is protected against concurrent access. Possible value: 0
or 1
. Default to 1
.Categories are declared in [CATEGORY::<category>] section.
[CATEGORY::default] is a predefined category which will be used if no other category match the wanted logger.
Configuration values for categories are:
logger.writers
: the writers to use. Possible value: writers list separated by '
,' .logger.level
: the minimum level of messages which will be logged by this logger. Possible value: level in lower case.Configuration file:
Application code: