This class is a still abstract implementation of class Logger which is used as the super class for all textual Logger implementations within ALox , e.g. ConsoleLogger.
The class uses a helper class to generate the textual representation of the meta information of a log call. This helper can be extended and replaced in MetaInfo to modify the behavior of TextLogger.
The final log message is then passed to the abstract method logText. Hence, custom Logger classes that inherited from this class instead of directly from class Logger, need to implement logText instead of implementing Log.
Class TextLogger supports multi line log outputs. Such multi line log outputs can be configured to be logged in different ways. See MultiLineMsgMode for more information.
Definition at line 436 of file textlogger.hpp.
#include <textlogger.hpp>
Public Type Index: | |
enum class | LightColorUsage { Auto , Never , Foreground , Background } |
Public Field Index: | |
strings::util::AutoSizes | AutoSizes |
ObjectConverter * | Converter = nullptr |
String16 | FmtMsgSuffix |
String64 | FmtMultiLineMsgHeadline = A_CHAR("ALox: Multi line message follows: ") |
String16 | FmtMultiLinePrefix = A_CHAR(">> ") |
String16 | FmtMultiLineSuffix = A_CHAR("") |
textlogger::MetaInfo * | MetaInfo |
AString | MultiLineDelimiter |
String16 | MultiLineDelimiterRepl = A_CHAR("\\r") |
int | MultiLineMsgMode =2 |
Public Field Index: inherited from Logger | |
integer | CntLogs =0 |
time::Ticks | TimeOfCreation |
time::Ticks | TimeOfLastLog |
Public Field Index: inherited from ThreadLock | |
NCString | DbgOwnerFile =nullptr |
NCString | DbgOwnerFunc =nullptr |
int | DbgOwnerLine |
uint16_t | DbgRecursionWarningThreshold =10 |
integer | DbgWarningAfterWaitTimeInMillis =2000L |
Public Method Index: | |
virtual ALIB_API | ~TextLogger () override |
virtual ALIB_API void | AcknowledgeLox (LoxImpl *lox, lang::ContainerOp op) override |
virtual ALIB_API void | ClearReplacements () |
virtual ALIB_API void | Log (Domain &domain, Verbosity verbosity, Boxes &logables, ScopeInfo &scope) override |
virtual ALIB_API void | ResetAutoSizes () |
virtual ALIB_API void | SetReplacement (const String &searched, const String &replacement) |
Public Method Index: inherited from Logger | |
virtual | ~Logger () |
const NString & | GetName () const |
const NString & | GetTypeName () const |
Public Method Index: inherited from SmartLock | |
SmartLock () | |
void | Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc) |
ALIB_API int | AddAcquirer (ThreadLock *newAcquirer) |
ALIB_API int | CntAcquirers () |
ALIB_API void | Release () |
defined(ALIB_DOX) | |
ALIB_API int | RemoveAcquirer (ThreadLock *acquirer) |
Public Method Index: inherited from ThreadLock | |
ALIB_API | ThreadLock (lang::Safeness safeness=lang::Safeness::Safe) |
ALIB_API | ~ThreadLock () |
ALIB_API void | Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc) |
int | CountAcquirements () const |
Thread * | GetOwner () const |
lang::Safeness | GetSafeness () const |
bool | IsOwnedByCurrentThread () const |
ALIB_API void | Release () |
defined(ALIB_DOX) | |
ALIB_API void | SetSafeness (lang::Safeness safeness) |
bool | WillRelease () const |
Additional Inherited Members | |
Public Static Field Index: inherited from SmartLock | |
static ALIB_API SmartLock | StdOutputStreams |
|
strong |
Denotes the use of light vs dark colors. Used with descendant classes only.
Enumerator | |
---|---|
Auto | Automatic. |
Never | Never use light colors. |
Foreground | Use light colors for foreground. |
Background | Use light colors for background. |
Definition at line 468 of file textlogger.hpp.
Holds a list of values for auto tab positions and field sizes. For each requested value, a corresponding array field is created on the fly. If the format string get's changed and different (new) auto values should be used, then this field should be reset after setting the new format string. The other way round, it is also possible to preset set minimum values for tabs and field sizes and hence avoid the columns growing during the lifetime of the Logger.
This field will be read from configuration variable ALOX_LOGGERNAME_AUTO_SIZES when this TextLogger is attached to a Lox and written back on removal.
Definition at line 523 of file textlogger.hpp.
ObjectConverter* Converter = nullptr |
A helper object to get textual representation of logable objects. If no converter is set when this logger is attached to a lox, a converter of type StandardConverter is created and used. Custom loggers might create their own, custom converter objects here. In the destructor of this class, the current object converter will be deleted.
To extend class TextLogger to support logging custom objects, custom converters can set. The preferred alternative is however, to make custom types be formattable by formatter classes used with StandardConverter.
Definition at line 491 of file textlogger.hpp.
String16 FmtMsgSuffix |
Characters written after each Log Statement. This may be used for example to reset colors and styles. Note, that with multi-line Log Statements, the contents of this field is not written at the end of each line, but only at the end of the last line. To define characters that are written after each line of a multi-line Log Statement, field FmtMultiLineSuffix.
Defaults to empty string.
Definition at line 510 of file textlogger.hpp.
Headline for multi line messages (depending on MultiLineMsgMode) . Defaults to "ALox: Multi line message follows: "
Definition at line 566 of file textlogger.hpp.
Prefix for multi line messages. This is also used if multi line messages logging is switched off (MultiLineMsgMode == 0) but replacing of a set MultiLineDelimiter takes place. Defaults to ">> ".
Definition at line 574 of file textlogger.hpp.
Suffix for multi line messages. This is also used if multi line messages logging is switched off (MultiLineMsgMode == 0) and replacing of a set MultiLineDelimiter takes place.
Note that at the end of the last line, in addition FmtMsgSuffix is added.
Defaults to "".
Definition at line 583 of file textlogger.hpp.
|
protected |
The internal log Buffer.
Definition at line 445 of file textlogger.hpp.
A helper object to format log objects into textual representations. This class incorporates a format string that defines the meta information in the log output. Furthermore, to extend TextLogger, this object can be replaced by custom implementations of it.
Definition at line 498 of file textlogger.hpp.
|
protected |
The buffers for converting the logables.
Definition at line 448 of file textlogger.hpp.
AString MultiLineDelimiter |
This is the string interpreted as line delimiter within log messages. If nulled, then '\n'
, '\r'
or '\r\n'
is recognized.
Important: Can be set to an empty string, to stop any multi line processing of TextLogger, even the replacements of the delimiter character.
Definition at line 553 of file textlogger.hpp.
This is the readable (!) separator string, for logging out multi line messages into a single line (MultiLineMsgMode==0). Defaults to "\\r".
Definition at line 560 of file textlogger.hpp.
int MultiLineMsgMode =2 |
Determines if multi line messages should be split into different log lines. Possible values are:
Definition at line 545 of file textlogger.hpp.
|
protected |
A list of pairs of strings. Within each log message, the first string of a pair is searched and replaced by the second string. Very simple, but useful in some cases.
Definition at line 464 of file textlogger.hpp.
|
protected |
Used to avoid repeated registration with ALib standard output stream lockers when attached to multiple instances of class Lox.
Definition at line 457 of file textlogger.hpp.
|
protected |
Denotes whether this logger writes to the standard output streams. If so, SmartLock::StdOutputStreams is acquired on logging.
Definition at line 452 of file textlogger.hpp.
|
explicitprotected |
Constructs a TextLogger. Reads the format variable for the meta information from the configuration. The variable name is created from the Logger name and the suffix '_FORMAT'
pName | The name of the Logger. |
typeName | The type of the Logger. |
pUsesStdStreams | Denotes whether this logger writes to the standard output streams. |
Definition at line 571 of file textlogger.cpp.
|
overridevirtual |
|
overridevirtual |
Configuration variables are read within this method and created with default values, in the case they do not exist, yet. The variables read and optionally created are:
Configuration variables are documented here.
Furthermore, invokes grand-parent's method SmartLock::AddAcquirer , respectively SmartLock::RemoveAcquirer and in addition, if field usesStdStreams is set, registers with SmartLock::StdOutputStreams .
lox | The Lox to acknowledge insertion or removal |
op | The operation. Either ContainerOp::Insert or ContainerOp::Remove. |
Reimplemented from Logger.
Definition at line 588 of file textlogger.cpp.
|
virtual |
Removes all pairs of searched strings and their replacement value.
Definition at line 854 of file textlogger.cpp.
|
overridevirtual |
This is the implementation of the abstract method inherited from class Logger that executes a log.
This class implements this method and but exposes the new abstract method logText. This mechanism allows this class to do various things that are standard to Loggers of type TextLogger. For example, meta information of the log invocation is formatted and string replacements are performed. This way, descendants of this class will consume a ready to use log buffer with all meta information and contents of all objects to be included and their primary obligation is to copy the content into a corresponding output stream.
domain | The Log Domain. |
verbosity | The verbosity. |
logables | The list of objects to log. |
scope | Information about the scope of the Log Statement.. |
Implements Logger.
Definition at line 865 of file textlogger.cpp.
|
protectedpure virtual |
This abstract method introduced by this class "replaces" the abstract method Log of parent class Logger which this class implements. In other words, descendants of this class need to override this method instead of Log. This class TextLogger is responsible for generating meta information, doing text replacements, handle multi-line messages, etc. and provides the textual representation of the whole log contents to descendants using this method.
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. |
msg | The log message. |
scope | Information about the scope of the Log Statement. |
lineNumber | The line number of a multi-line message, starting with 0. For single line messages this is -1. |
Implemented in WindowsConsoleLogger, PlainTextLogger, and AnsiLogger.
|
protectedpure virtual |
Abstract method to be implemented by descendants. This message is called only when multi-line messages are logged. It is called exactly once before a series of logText calls of a multi-line message and exactly once after such series.
This is useful if the writing of text includes the acquisition of system resources (e.g. opening a file).
phase | Indicates the beginning or end of a multi-line operation. |
Implemented in TextFileLogger, VStudioLogger, WindowsConsoleLogger, AnsiLogger, ConsoleLogger, and MemoryLogger.
|
virtual |
Resets automatically widened tab stops and field widths of this logger by calling ResetAutoSizes on field Converter.
Definition at line 859 of file textlogger.cpp.
Adds the given pair of replacement strings. If searched string already exists, the current replacement string gets replaced. If the replacement string is nullptr
, nothing is set and a previously set replacement definition becomes unset.
searched | The string to be searched. |
replacement | The replacement string. If this equals 'nullptr' a previously set replacement will be unset. |
Definition at line 828 of file textlogger.cpp.