Logger class.
More...
#include <SystemLogger.h>
|
| | Logger (const char *name="") |
| | Constructor.
|
| |
| | Logger (LogStreamBuf *streambuf) |
| | Constructor.
|
| |
| | ~Logger () override |
| | Virtual destructor.
|
| |
| bool | setLevel (const char *level) |
| | Set log level by string.
|
| |
| void | setDateFormat (const char *format) |
| | Set date/time format for adding the header.
|
| |
| void | setClockType (const std::string &clocktype) |
| | Specifying clock type to be used for logging.
|
| |
| void | setName (const char *name) |
| | Set suffix of date/time string of header.
|
| |
| void | write (int level, const std::string &mes) override |
| | log output
|
| |
| void | write (int level, const coil::Properties &prop) |
| | log output
|
| |
|
| std::string | getDate () |
| | Get the current formatted date/time string Get the current datetime described by specified format.
|
| |
|
| static int | strToLevel (const char *level) |
| | Set the log level Set the log level corresponding to the given string.
|
| |
Logger class.
This class is composed of the buffer class and the format class.
- The buffer class
- The buffer class serializes to the MultiThreading writing and does buffering.
- The buffer class can output the log at two or more output destination. As the example of the output destination, filing, the standard, the log server etc.
- The output destination can be added to the buffer with addStream.
- The format class
- The format class can output it by specifying the log level.
- The format is [Time] [Loglevel] [Ssuffix] [Message].
- [Time] [Loglevel] [Suffix] are added by the automatic operation.
- [Suffix] can be specified.
- Loglevel
- RTL_SILENT
- RTL_FATAL
- RTL_ERROR
- RTL_WARN
- RTL_INFO
- RTL_DEBUG
- RTL_TRACE
- RTL_VERBOSE
- RTL_PARANOID
- The format class can be locked/unlocked to this format object.
◆ anonymous enum
| Enumerator |
|---|
| RTL_SILENT | |
| RTL_FATAL | |
| RTL_ERROR | |
| RTL_WARN | |
| RTL_INFO | |
| RTL_DEBUG | |
| RTL_TRACE | |
| RTL_VERBOSE | |
| RTL_PARANOID | |
◆ Logger() [1/2]
| RTC::Logger::Logger |
( |
const char * | name = "" | ) |
|
|
explicit |
Constructor.
Constructor
- Parameters
-
| name | suffix of date/time string of header. |
◆ Logger() [2/2]
Constructor.
Constructor
- Parameters
-
| streambuf | LogStream object |
◆ ~Logger()
◆ getDate()
| std::string RTC::Logger::getDate |
( |
| ) |
|
|
protected |
Get the current formatted date/time string Get the current datetime described by specified format.
- Returns
- Format specification current datetime
◆ getLevelColor()
| static std::string RTC::Logger::getLevelColor |
( |
int | level | ) |
|
|
inlinestatic |
◆ getLevelOutputString()
| static std::string RTC::Logger::getLevelOutputString |
( |
int | level | ) |
|
|
inlinestatic |
◆ getLevelString()
| static std::string RTC::Logger::getLevelString |
( |
int | level | ) |
|
|
inlinestatic |
◆ setClockType()
| void RTC::Logger::setClockType |
( |
const std::string & | clocktype | ) |
|
Specifying clock type to be used for logging.
This function sets a clock type getting time when it is used for logging. Available clock types are,
- system: System clock. Default option.
- logical: Logical time clock.
- adjusted: Adjusted clock.
To use logical time clock, call and set time by the following function in somewhere.
coil::ClockManager::instance().getClock("logical").settime()
- Parameters
-
| clocktype | A clock type above mentioned |
◆ setDateFormat()
| void RTC::Logger::setDateFormat |
( |
const char * | format | ) |
|
Set date/time format for adding the header.
The format specification string is as follows:
%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c the standard date and time string
%d day of the month, as a number (1-31)
%H hour, 24 hour format (0-23)
%I hour, 12 hour format (1-12)
%j day of the year, as a number (1-366)
%m month as a number (1-12).
Note: some versions of Microsoft Visual C++ may use values that range
from 0-11.
%M minute as a number (0-59)
%p locale's equivalent of AM or PM
%Q millisecond as a number (0-999) from ver 1.1
%q microsecond as a number (0-999) from ver 1.1
%S second as a number (0-59)
%U week of the year, sunday as the first day
%w weekday as a decimal (0-6, sunday=0)
%W week of the year, monday as the first day
%x standard date string
%X standard time string
%y year in decimal, without the century (0-99)
%Y year in decimal, with the century
%Z time zone name
%% a percent sign
- Parameters
-
◆ setLevel()
| bool RTC::Logger::setLevel |
( |
const char * | level | ) |
|
Set log level by string.
- Parameters
-
◆ setName()
| void RTC::Logger::setName |
( |
const char * | name | ) |
|
Set suffix of date/time string of header.
Set the suffix string added after the datatime of the header.
- Parameters
-
◆ strToLevel()
| static int RTC::Logger::strToLevel |
( |
const char * | level | ) |
|
|
staticprotected |
Set the log level Set the log level corresponding to the given string.
- Parameters
-
- Returns
- The set log level
◆ write() [1/2]
| void RTC::Logger::write |
( |
int | level, |
|
|
const coil::Properties & | prop ) |
log output
- Parameters
-
| level | log level |
| prop | properties |
◆ write() [2/2]
| void RTC::Logger::write |
( |
int | level, |
|
|
const std::string & | mes ) |
|
override |
log output
- Parameters
-
| level | log level |
| mes | message |
The documentation for this class was generated from the following file: