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 two helper classes. One to convert the log message object into a string representation and a second to generate the textual representation of the meta information of a log call. These helpers can be extended and replaced 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.
Public Fields | |
AutoSizes | AutoSizes = new AutoSizes() |
ObjectConverter | Converter |
String | FmtMsgSuffix ="" |
String | FmtMultiLineMsgHeadline ="ALox: Multi line message follows: " |
Headline for multi line messages (depending on MultiLineMsgMode). | |
String | FmtMultiLinePrefix =">> " |
String | FmtMultiLineSuffix =null |
MetaInfo | MetaInfo =new MetaInfo() |
String | MultiLineDelimiter =null |
String | MultiLineDelimiterRepl ="\\r" |
int | MultiLineMsgMode =2 |
Public Fields inherited from Logger | |
int | CntLogs |
Ticks | TimeOfCreation = new Ticks() |
The creation time of the Logger. | |
Ticks | TimeOfLastLog = new Ticks() |
Timestamp of the last log operation. | |
Public Fields inherited from ThreadLock | |
int | RecursionWarningThreshold =10 |
int | waitWarningTimeLimitInMillis =1000 |
Public Methods | |
override int | AddAcquirer (ThreadLock newAcquirer) |
void | ClearReplacements () |
override void | Log (Domain domain, Verbosity verbosity, List< Object > logables, ScopeInfo scope) |
override int | RemoveAcquirer (ThreadLock acquirer) |
void | ResetAutoSizes () |
void | SetReplacement (String searched, String replacement) |
Public Methods inherited from Logger | |
String | GetName () |
String | GetTypeName () |
override String | ToString () |
Public Methods inherited from SmartLock | |
SmartLock () | |
int | CntAcquirers () |
Public Methods inherited from ThreadLock | |
ThreadLock (LockMode lockMode=LockMode.Recursive, Safeness safeness=Safeness.Safe) | |
virtual void | Acquire ([CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="") |
int | DbgCountAcquirements (Thread thread=null) |
LockMode | GetMode () |
Safeness | GetSafeness () |
virtual void | Release () |
void | SetSafeness (Safeness safeness) |
override String | ToString () |
bool | WillRelease () |
Protected Fields | |
AString | logBuf =new AString( 256 ) |
AString | msgBuf =new AString( 128 ) |
List< String > | replacements =new List<String>() |
int | stdStreamLockRegistrationCounter =0 |
bool | usesStdStreams |
Protected Fields inherited from Logger | |
String | Name |
String | TypeName |
Protected Fields inherited from SmartLock | |
List< ThreadLock > | acquirers =new List<ThreadLock>() |
Protected Fields inherited from ThreadLock | |
int | cntAcquirements |
LockMode | lockMode |
Object | mutex |
Thread | owner |
Ticks | waitTime =new Ticks() |
Protected Methods | |
TextLogger (String name, String typeName, bool usesStdStreams) | |
abstract void | logText (Domain domain, Verbosity verbosity, AString msg, ScopeInfo scope, int lineNumber) |
abstract void | notifyMultiLineOp (Phase phase) |
Protected Methods inherited from Logger | |
Logger (String name, String typeName) | |
|
inlineprotected |
Constructs a TextLogger.
|
inlinevirtual |
Invokes grand-parent's method and in addition, if field usesStdStreams is set, registers with ALIB.StdOutputStreamsLock.
newAcquirer | The acquirer to add. |
Reimplemented from SmartLock.
|
inline |
Removes all pairs of searched strings and their replacement value.
|
inlinevirtual |
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. This has been checked to be active already on this stage and is provided to be able to be logged out only. |
logables | The list of objects to log. |
scope | Information about the scope of the Log Statement.. |
Implements Logger.
|
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 overwrite 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 AnsiLogger, ColorConsoleLogger, and PlainTextLogger.
|
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 AnsiLogger, ColorConsoleLogger, TextFileLogger, CLRDebuggerLogger, ConsoleLogger, and MemoryLogger.
|
inlinevirtual |
Invokes grand-parent's method and in addition, de-registers with ALIB.StdOutputStreamsLock.
acquirer | The acquirer to remove. |
Reimplemented from SmartLock.
|
inline |
Resets automatically widened tab stops and field widths of this logger by calling ResetAutoSizes on field Converter.
|
inline |
Adds the given pair of replacement strings. If searched string already exists, the current replacement string gets replaced. If the replacement string is null
, nothing is set and a previously set replacement definition becomes unset.
searched | The string to be searched. |
replacement | The replacement string. If this equals null a previously set replacement will be unset. |
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 the configuration variable ALOX_LOGGERNAME_AUTO_SIZES when the TextLogger that we belong to is attached to a Lox and written back on removal.
ObjectConverter Converter |
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.
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.
String 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.
String FmtMultiLinePrefix =">> " |
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.
String FmtMultiLineSuffix =null |
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 "".
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.
String MultiLineDelimiter =null |
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.
String MultiLineDelimiterRepl ="\\r" |
This is the readable (!) separator string, for logging out multi line messages into a single line (MultiLineMsgMode==0).
int MultiLineMsgMode =2 |
Determines if multi line messages should be split into different log lines. Possible values are:
|
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.
|
protected |
Used to avoid to repeatedly register with ALib standard output stream lockers when attached to multiple instances of class Lox.
|
protected |
Denotes whether this logger writes to the standard output streams.