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

Class Description


Provides high level functionality for logging things like Exceptions, objects and XML documents.

Public Static Fields

static String FmtExcNull ="<No exception given>"
 The String to log out if the exception parameter equals null.
 
static String FmtInstArrayPrefix ="array["
 Prefix before logging size of an IEnumberable.
 
static String FmtInstArraySuffix ="]"
 Suffix after logging IEnumberable.
 
static String FmtInstCycRefPrefix ="(Cyclic ref., see line <"
 Prefix before logging out a cyclic reference line number.
 
static String FmtInstCycRefSuffix =">)"
 Suffix after logging out a cyclic reference line number.
 
static String FmtInstIEnumerablePrefix ="IEnumerable, size= "
 Prefix before logging size of an IEnumberable.
 
static String FmtInstIEnumerableSuffix =""
 Suffix after logging IEnumberable.
 
static String FmtInstIndent =" "
 Indent String for instance lines.
 
static String FmtInstLineNoPrefix ="<"
 Prefix for instance line numbers.
 
static String FmtInstLineNoSuffix =">"
 Suffix for instance line numbers.
 
static String FmtInstNoAccessToValue ="<no access>"
 String for non-accessible members.
 
static String FmtInstNull ="<null>"
 The String to log out if a given object instance equals null.
 
static String FmtInstRecursionLimit ="(MAX REC) "
 
static String FmtInstTypePrefix ="{"
 Prefix for type names.
 
static String FmtInstTypeSuffix ="}"
 Suffix for type names.
 
static int instTypeTabStop =65
 Tab stop for types when logging instances.
 
static int instValueTabStop =35
 Tab stop for values when logging instances.
 

Public Static Methods

static void Exception (Exception e, String headline=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void Exception (String domain, Verbosity verbosity, Exception e, String headline=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void Exception (Verbosity verbosity, Exception e, String headline=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void Instance (String domain, Verbosity verbosity, Object o, int maxRecursion, String headline=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void Instance (Verbosity verbosity, Object o, int maxRecursion, String headline=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void XML (String domain, Verbosity verbosity, XDocument xDocument, String headLine=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void XML (String domain, Verbosity verbosity, XElement xElement, String headLine=null, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void XML (Verbosity verbosity, XDocument xDocument, String headLine, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 
static void XML (Verbosity verbosity, XElement xElement, String headLine, Lox lox=null, [CallerLineNumber] int cln=0,[CallerFilePath] String csf="",[CallerMemberName] String cmn="")
 

Protected Static Fields

static int instLineBeginIdx
 Instance index of beginning of line in toolBuf.
 
static uint instLineNumber
 Instance line number counter.
 
static Dictionary< Object, UInt32 > instObject2LineNumber
 Instance line number dictionary used to refer to already logged sub objects.
 
static ThreadLock Lock =new ThreadLock()
 
static AString tempBuf
 Temporary helper buffer.
 
static AString toolBuf
 Buffer to build log messages.
 

Protected Static Methods

static void exception (Exception e, String headline, int indent)
 
static void instBeginLine (int indent)
 
static void instMain (Object o, int maxRecursion, String headLine)
 
static void instNewLine ()
 
static void instRecursive (Object inst, int maxRecursion, int indent)
 
static void instTabStop (int tabStop)
 
static void instTabTypeAndNewLine (Type type)
 
static bool isValueType (Object o, Type type)
 
static void xml (XDocument xDocument, String headLine)
 
static void xmlElement (XElement xe, String headLine, int indent)
 

Member Function Documentation

◆ exception()

static void exception ( Exception  e,
String  headline,
int  indent 
)
inlinestaticprotected

Logs an exception.

Parameters
eThe exception to log.
headlineAn optional headline string preceding the exception.
indentThe indentation in the output (recursively increased). If set to -1 the 'headline' is logged.

◆ Exception() [1/3]

static void Exception ( Exception  e,
String  headline = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log an exception including inner exceptions recursively. Scope Domain is used with Verbosity.Error. Note: Calls to this method are automatically removed from release code.

Parameters
eThe Exception to log.
headline(Optional) A headline string to precede the exception with.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ Exception() [2/3]

static void Exception ( String  domain,
Verbosity  verbosity,
Exception  e,
String  headline = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log an exception including inner exceptions recursively. Note: Calls to this method are automatically removed from release code.

Parameters
domainThe Log Domain.
verbosityThe verbosity.
eThe Exception to log.
headline(Optional) A headline string to precede the exception with.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ Exception() [3/3]

static void Exception ( Verbosity  verbosity,
Exception  e,
String  headline = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log an exception including inner exceptions recursively. Scope Domain of file is used with Verbosity.Error. Note: Calls to this method are automatically removed from release code.

Parameters
verbosityThe verbosity.
eThe Exception to log.
headline(Optional) A headline string to precede the exception with.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ Instance() [1/2]

static void Instance ( String  domain,
Verbosity  verbosity,
Object  o,
int  maxRecursion,
String  headline = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Uses reflection to log an object.

Parameters
domainThe Log Domain which is combined with Scope Domains set for the Scope of invocation.
verbosityThe verbosity.
oThe object to be logged.
maxRecursionThe maximum depth of recursion for logging nested object.
headline(Optional) A headline string to precede the exception with.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ Instance() [2/2]

static void Instance ( Verbosity  verbosity,
Object  o,
int  maxRecursion,
String  headline = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Uses reflection to log an object.

Parameters
verbosityThe verbosity.
oThe object to be logged.
maxRecursionThe maximum depth of recursion for logging nested object.
headline(Optional) A headline string to precede the exception with.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ instBeginLine()

static void instBeginLine ( int  indent)
inlinestaticprotected

Appends line number (format defined in fields FmtInstLineNoPrefix and FmtInstLineNoSuffix) and then adds indent characters (defined in field FmtInstIndent).

Parameters
indentThe indentation of the line.

◆ instMain()

static void instMain ( Object  o,
int  maxRecursion,
String  headLine 
)
inlinestaticprotected

Logs the header and invokes instRecursive()

Parameters
oThe object to be logged.
maxRecursionThe maximum depth of recursion for logging nested object.
headLineThe headline to log.

◆ instNewLine()

static void instNewLine ( )
inlinestaticprotected

Adds a new line to the buffer and increases line number counter.

◆ instRecursive()

static void instRecursive ( Object  inst,
int  maxRecursion,
int  indent 
)
inlinestaticprotected

Recursively log an instance using reflection.

Parameters
instThe element.
maxRecursionThe maximum depth of recursion for logging nested object.
indentThe indentation in the output (recursively increased).

◆ instTabStop()

static void instTabStop ( int  tabStop)
inlinestaticprotected

Appends spaces to move to the given tabStop (but at least one).

Parameters
tabStopThe tab stop position to go to

◆ instTabTypeAndNewLine()

static void instTabTypeAndNewLine ( Type  type)
inlinestaticprotected

Appends type information at the end of the line and starts a new line.

Parameters
typeThe type to append in the log

◆ isValueType()

static bool isValueType ( Object  o,
Type  type 
)
inlinestaticprotected

Detects if the given object is of value type. Special treatment is given to KeyValuePair<,>. C# treat them as a value type that causes some irritation sometimes.

Parameters
oThe object to be tested.
typeThe type of the object (needed outside, therefore passed here to avoid double creation).
Returns
the value (if given object is of value type) or null otherwise.

◆ XML() [1/4]

static void XML ( String  domain,
Verbosity  verbosity,
XDocument  xDocument,
String  headLine = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log a XML document. Note: Calls to this method are automatically removed from release code.

Parameters
domainThe Log Domain which is combined with Scope Domains set for the Scope of invocation.
verbosityThe verbosity.
xDocumentthe XML document to be logged.
headLine(Optional) The headline to log.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ XML() [2/4]

static void XML ( String  domain,
Verbosity  verbosity,
XElement  xElement,
String  headLine = null,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log a XML element. Note: Calls to this method are automatically removed from release code.

Parameters
domainThe Log Domain which is combined with Scope Domains set for the Scope of invocation.
verbosityThe verbosity.
xElementthe answer node of the XML tree to be logged.
headLine(Optional) The headline to log.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ XML() [3/4]

static void XML ( Verbosity  verbosity,
XDocument  xDocument,
String  headLine,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log a XML document. Note: Calls to this method are automatically removed from release code.

Parameters
verbosityThe verbosity.
xDocumentthe XML document to be logged.
headLineThe headline to log.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ XML() [4/4]

static void XML ( Verbosity  verbosity,
XElement  xElement,
String  headLine,
Lox  lox = null,
[CallerLineNumber] int  cln = 0,
[CallerFilePath] String  csf = "",
[CallerMemberName] String  cmn = "" 
)
inlinestatic

Log a XML element. Note: Calls to this method are automatically removed from release code.

Parameters
verbosityThe verbosity.
xElementthe answer node of the XML tree to be logged.
headLineThe head line.
lox(Optional) The lox to log with. If null, the static member LOX of the static class Log is used.
cln(Optional) Caller info, compiler generated. Please omit.
csf(Optional) Caller info, compiler generated. Please omit.
cmn(Optional) Caller info, compiler generated. Please omit.

◆ xml()

static void xml ( XDocument  xDocument,
String  headLine 
)
inlinestaticprotected

Dump a XML document into our Buffer.

Parameters
xDocumentThe XDocument to be logged.
headLineThe headline to log.

◆ xmlElement()

static void xmlElement ( XElement  xe,
String  headLine,
int  indent 
)
inlinestaticprotected

Internal function for logging an XElement.

Parameters
xeThe XElement to log.
headLineThe headline to log.
indentThe indentation to Log.

Member Data Documentation

◆ FmtInstRecursionLimit

String FmtInstRecursionLimit ="(MAX REC) "
static

Prefix before logging out a string representation of a member because recursion limit was reached.

◆ Lock

ThreadLock Lock =new ThreadLock()
staticprotected

This is the ThreadLock (mutex) which each method of this class uses to lock resources, e.g. the toolBuf


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