ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | Protected Fields | Protected Methods | List of all members
MetaInfo Class Reference
Collaboration diagram for MetaInfo:
[legend]

Class Description


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:

Public Fields

String DateFormat = "yyyy-MM-dd"
 
AString Format = new AString( "%SF(%SL):%A5%SM() %A5[%TC +%TL][%tN]%V[%D]%A1(%#): " )
 
int LogNumberMinDigits = 3
 Prefix for the domain.
 
Ticks MaxElapsedTime = new Ticks(0)
 
AString NoMethodInfo = new AString( "---" )
 Replacement string if no source info is available.
 
AString NoSourceFileInfo = new AString( "---" )
 Replacement string if no source info is available.
 
String TimeDiffDays = " days"
 Format for time difference outputs of more than a day.
 
String TimeDiffHours = " h"
 Format for time difference outputs between 1h and 24h.
 
String TimeDiffMicros = " \u00B5s"
 Entity microseconds for time difference outputs below 1000 microseconds.
 
String TimeDiffMillis = " ms"
 Entity milliseconds for time difference outputs below 1000 milliseconds.
 
long TimeDiffMinimum = 1000L
 Minimum time difference to log in nanoseconds. Below that TimeDiffNone is written.
 
String TimeDiffMins = " m"
 Format for time difference outputs between 100s and 60 min.
 
String TimeDiffNanos = " ns"
 Entity nanoseconds for time difference outputs below 1000 microseconds.
 
String TimeDiffNone = " 0 ns"
 Output for time difference if below reasonable (measurable) minimum defined in TimeDiffMinimum.
 
String TimeDiffSecs = " s"
 Format for time difference outputs between 10s and 99.9s.
 
String TimeElapsedDays = " Days "
 The word "Days" the out put of time elapsed (if longer than a day).
 
String TimeOfDayFormat = "HH:mm:ss"
 
String VerbosityError = "[ERR]"
 
String VerbosityInfo = " "
 
String VerbosityVerbose = "[***]"
 
String VerbosityWarning = "[WRN]"
 

Public Methods

virtual void Write (TextLogger logger, AString buffer, Domain domain, Verbosity verbosity, ScopeInfo scope)
 

Protected Fields

DateTime? callerDateTime
 A singleton DateTime object shared between different format variables during one invocation.
 
String dateFormatString
 The .Net format string built at runtime to {0:FmtDate}.
 
String detectDateFormatChanges
 Reference to last date format string to detect changes at runtime.
 
String detectTimeOfDayFormatChanges
 Reference to last time of day format string to detect changes at runtime.
 
Ticks elapsedTime =new Ticks(0)
 
StringBuilder formatSB = new StringBuilder( 64 )
 Internal string builder used for formatting operations.
 
String timeOfDayFormatString
 The .Net format string built at runtime to {0:FmtTimeOfDay}.
 
AString tmpAString =new AString()
 
Tokenizer tTok =new Tokenizer()
 Tokenizer used in Write.
 
bool warnedOnce = false
 

Protected Methods

virtual void processVariable (TextLogger logger, Domain domain, Verbosity verbosity, ScopeInfo scope, AString dest, Substring variable)
 
virtual void writeTimeDiff (AString buf, long diffNanos)
 

Member Function Documentation

◆ processVariable()

virtual void processVariable ( TextLogger  logger,
Domain  domain,
Verbosity  verbosity,
ScopeInfo  scope,
AString  dest,
Substring  variable 
)
inlineprotectedvirtual

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 returns, the command is cut from the front.

Parameters
loggerThe logger that we are embedded in.
domainThe Log Domain.
verbosityThe verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only.
scopeInformation about the scope of the Log Statement..
destThe buffer to write meta information into.
variableThe variable to read (may have more characters appended)

◆ Write()

virtual void Write ( TextLogger  logger,
AString  buffer,
Domain  domain,
Verbosity  verbosity,
ScopeInfo  scope 
)
inlinevirtual

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.

Parameters
loggerThe logger that we are embedded in.
bufferThe buffer to write meta information into.
domainThe Log Domain.
verbosityThe verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only.
scopeInformation about the scope of the Log Statement..

◆ writeTimeDiff()

virtual void writeTimeDiff ( AString  buf,
long  diffNanos 
)
inlineprotectedvirtual

Helper function that logs a time given difference into the given buffer in a human readable format. Works from micro seconds to days.

Parameters
bufThe buffer to write the time difference representation into.
diffNanosThe time difference to write in nanoseconds.

Member Data Documentation

◆ DateFormat

String DateFormat = "yyyy-MM-dd"

Format string for the output of the log date. For more information, see "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat()

◆ elapsedTime

Ticks elapsedTime =new Ticks(0)
protected

A reusable Ticks object.

◆ Format

AString Format = new AString( "%SF(%SL):%A5%SM() %A5[%TC +%TL][%tN]%V[%D]%A1(%#): " )

The line format specifies the (automated) log output that is prepended to each log line before the log message itself.

The string supports replacement variables that begin with a % sign

  • SP: The full path of the source file
  • Sp: The trimmed path of the source file
  • SF: The callers' source file name
  • Sf: The callers' source file name without extension
  • SL: The line number in the source file
  • SM: The method name
  • TD: The date the log call was invoked
  • TT: Time of day the log call was invoked
  • TC: Time elapsed since the Logger was created or its timer was reset
  • TL: Time elapsed since the last log call
  • tN: Thread name
  • tI: Thread ID
  • V: The verbosity. This is replaced by the corresponding strings found in fields VerbosityError, VerbosityWarning, VerbosityInfo and VerbosityVerbose.
  • D: Log domain
  • %#: The log call counter (like a line counter, but counting multi lines as one)
  • An: An auto-adjusted tabulator. This grows whenever it needs, but never shrinks. The optional integer number n specifies how much extra space is added when tab is adjusted. Setting this to a higher value avoids too many adjustments at the beginning of a log session.
  • LG: The name of the Logger. This might be useful if multiple loggers write to the same output stream (e.g. Console).
  • LX: The name of the Lox.
  • P: The name of the process / application.

Defaults to

"%Sp/%SF(%SL):%A5%SM() %A5[%TC +%TL][%tN]%V[%D]%A1(%#): "

◆ MaxElapsedTime

Ticks MaxElapsedTime = new Ticks(0)

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.

◆ TimeOfDayFormat

String TimeOfDayFormat = "HH:mm:ss"

Format string for the output of the time of day. For more information, see "Standard Date and Time Format Strings" in .NET StringBuilder.AppendFormat()

◆ tmpAString

AString tmpAString =new AString()
protected

A reusable AString .

◆ VerbosityError

String VerbosityError = "[ERR]"

The replacement for variable %V in field Format if Verbosity is Error

◆ VerbosityInfo

String VerbosityInfo = " "

The replacement for variable %V in field Format if Verbosity is Info

◆ VerbosityVerbose

String VerbosityVerbose = "[***]"

The replacement for variable %V in field Format if Verbosity is Verbose

◆ VerbosityWarning

String VerbosityWarning = "[WRN]"

The replacement for variable %V in field Format if Verbosity is Warning

◆ warnedOnce

bool warnedOnce = false
protected

Helper flag that indicates if a format warning report was already issued


The documentation for this class was generated from the following file: