This class is a sort of plug-in for the TextLogger class. Its purpose is to assemble the meta information of each log line (things like timestamps, thread information, verbosity and domain, etc.).
To manipulate the meta information log output, three options exist:
Definition at line 181 of file textlogger.hpp.
#include <textlogger.hpp>
Public Field Index: | |
TickConverter | DateConverter |
String32 | DateFormat = A_CHAR("yyyy-MM-dd") |
AString | Format { A_CHAR("%SF:%SL:%A3%SM %A3[%TC +%TL][%tN]%V[%D]%A1#%#: ")} |
bool | FormatWarningOnce = false |
int | LogNumberMinDigits = 3 |
Ticks::Duration | MaxElapsedTime |
NString16 | NoMethodInfo = "---" |
NString16 | NoSourceFileInfo = "---" |
String16 | TimeDiffDays = A_CHAR(" days") |
String16 | TimeDiffHours = A_CHAR(" h") |
String16 | TimeDiffMicros = A_CHAR(" \u00B5s") |
String16 | TimeDiffMillis = A_CHAR(" ms") |
int64_t | TimeDiffMinimum =1000L |
String16 | TimeDiffMins = A_CHAR(" m") |
String16 | TimeDiffNanos = A_CHAR(" ns") |
String16 | TimeDiffNone = A_CHAR("--- ") |
String16 | TimeDiffSecs = A_CHAR(" s") |
String16 | TimeElapsedDays = A_CHAR(" Days ") |
String16 | TimeOfDayFormat = A_CHAR("HH:mm:ss") |
String16 | VerbosityError = A_CHAR("[ERR]") |
String16 | VerbosityInfo = A_CHAR(" ") |
String16 | VerbosityVerbose = A_CHAR("[***]") |
String16 | VerbosityWarning = A_CHAR("[WRN]") |
Public Method Index: | |
MetaInfo () | |
virtual | ~MetaInfo () |
virtual ALIB_API void | Write (TextLogger &logger, AString &buffer, detail::Domain &domain, Verbosity verbosity, ScopeInfo &scope) |
|
protected |
A singleton calendar time object shared between different format variables during one invocation.
Definition at line 341 of file textlogger.hpp.
TickConverter DateConverter |
This field is used to convert the steady and monotonic clock values provided with ScopeInfo::GetTimeStamp into human readable, calendrical values in the moment, field Format contains tokens %TD
and/or %TT
.
This may become problematic and ambiguous if the system clock is changed during a software run. Especially for long-running background software (daemons, servers, etc.), the software that uses ALox needs to provide a strategy of synchronizing this converter with the system clock.
A simple strategy is to just periodically invoke TickConverter::SyncClocks , for example once a second.
For some explanation of the problem see details of namespace alib::time.
Definition at line 332 of file textlogger.hpp.
Format string for the output of the log date. For more information, see "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat().
Definition at line 261 of file textlogger.hpp.
The line format specifies the (automated) log output that is prepended to each log line before the log message itself. This format string can be changed after the creation of a TextLogger.
The string supports replacement variables that begin with a % sign
Defaults to
If debug logging as well as release logging has scope information disabled (see ALOX_DBG_LOG_CI and ALOX_REL_LOG_CI), then it defaults to: "[%TC +%TL][%tN]%V[%D]%A1(%#): "
%TD
and %TT
may become problematic and ambiguous if the system clock is changed during a software run. Especially for long-running background software (daemons, servers, etc.), the software that uses ALox needs to provide a strategy of synchronizing the clock with field DateConverter.Definition at line 234 of file textlogger.hpp.
bool FormatWarningOnce = false |
If false
, an one-time warning (using ALIB_WARNING) will be issued if the format string is illegal. With each warning, the flag is set to true
to omit further warnings.
Definition at line 244 of file textlogger.hpp.
int LogNumberMinDigits = 3 |
The minimum digits to write for the log number (if used in format string).
Definition at line 304 of file textlogger.hpp.
Ticks::Duration MaxElapsedTime |
The maximum time elapsed. Used to determine the width of the output when writing the elapsed time.
This field will be read from the configuration variable ALOX_LOGGERNAME_MAX_ELAPSED_TIME when the TextLogger that this object belongs to is attached to a Lox and written back on removal.
Definition at line 314 of file textlogger.hpp.
NString16 NoMethodInfo = "---" |
Replacement string if no source info is available.
Definition at line 301 of file textlogger.hpp.
NString16 NoSourceFileInfo = "---" |
Replacement string if no source info is available.
Definition at line 298 of file textlogger.hpp.
Format for time difference outputs of more than a day.
Definition at line 295 of file textlogger.hpp.
Format for time difference outputs between 1h and 24h.
Definition at line 292 of file textlogger.hpp.
Entity microseconds for time difference outputs below 1000 microseconds.
Definition at line 280 of file textlogger.hpp.
Entity milliseconds for time difference outputs below 1000 milliseconds.
Definition at line 283 of file textlogger.hpp.
int64_t TimeDiffMinimum =1000L |
Minimum time difference to log in nanoseconds. Below that TimeDiffNone is written.
Definition at line 271 of file textlogger.hpp.
Format for time difference outputs between 100s and 60 min.
Definition at line 289 of file textlogger.hpp.
Entity nanoseconds for time difference outputs below 1000 microsecond.
Definition at line 277 of file textlogger.hpp.
Output for time difference if below reasonable (measurable) minimum defined in TimeDiffMinimum.
Definition at line 274 of file textlogger.hpp.
Format for time difference outputs between 10s and 99.9s.
Definition at line 286 of file textlogger.hpp.
The word "Days" the out put of time elapsed (if longer than a day).
Definition at line 268 of file textlogger.hpp.
Format string for the output of the time of day. For more information, see "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat().
Definition at line 265 of file textlogger.hpp.
The replacement for variable %V
in field Format if Verbosity is Error
.
Definition at line 248 of file textlogger.hpp.
The replacement for variable %V
in field Format if Verbosity is Info
.
Definition at line 254 of file textlogger.hpp.
The replacement for variable %V
in field Format if Verbosity is Verbose
.
Definition at line 257 of file textlogger.hpp.
The replacement for variable %V
in field Format if Verbosity is Warning
.
Definition at line 251 of file textlogger.hpp.
|
inline |
|
inlinevirtual |
|
protectedvirtual |
Processes the next command found in the format string, by writing formatted information into the given buffer. The given Substring holds the next command. When method the returns, the command is cut from the front.
logger | The logger that we are embedded in. |
domain | The Log Domain. |
verbosity | The verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only. |
scope | Information about the scope of the Log Statement.. |
dest | The buffer to write meta information into. |
variable | The variable to read (may have more characters appended) |
Definition at line 160 of file textlogger.cpp.
|
virtual |
Parses the Format string and logs meta information into the log buffer. For each variable found, method processVariable is invoked. Hence, to add new variables, the latter method can be overwritten by descendants. Overwriting this method is recommended for formatter classes that do not rely on format strings.
logger | The logger that we are embedded in. |
buffer | The buffer to write meta information into. |
domain | The Log Domain. |
verbosity | The verbosity. |
scope | Information about the scope of the Log Statement.. |
Definition at line 133 of file textlogger.cpp.
|
protectedvirtual |
Helper function that logs a time given difference into the given buffer in a human readable format. Works from nanoseconds seconds to days.
buffer | The buffer to write the time difference representation into. |
diffNanos | The time difference to write in nanoseconds. |
Definition at line 415 of file textlogger.cpp.