OpenPetra
Free Administration Software for Non-Profits
Ict.Common.TLogging Class Reference

The TLogging class provides general logging functionality. Logging output can currently go to the Console, to a file or to both at the same time. More...

Public Member Functions

delegate void TStatusCallbackProcedure (string msg)
 this is used for statusbar updates More...
 
delegate void TLogNewMessageCallback ()
 his is used for Windows Forms logging More...
 
 TLogging ()
 Creates a Console-only logger. More...
 
 TLogging (String AFileName, bool ASuppressDateAndTime=false)
 Creates a logger that can log both to Console or file. More...
 
bool CanWriteLogFile (out String ALogFileMsg)
 

Static Public Member Functions

static void ResetStaticVariables ()
 reset the static variables for each Web Request call. More...
 
static void SendConsoleOutputToString (TLogNewMessageCallback ANewMessageCallback)
 Call this method on Windows Forms apps to send the 'console' output to a dynamic string More...
 
static String GetLogFileName ()
 returns the name of the current log file More...
 
static void SetContext (String context)
 Set the context of the program situation. It is displayed in the next log messages. More...
 
static void SetStatusBarProcedure (TStatusCallbackProcedure callbackfn)
 This sets the procedure that is called with the text as an parameter. It can be used to update a status bar. More...
 
static String GetConsoleLog ()
 Gets the current console log text. Throws an exception if the console text is being written to a console. You should call SendConsoleOutputToString to send output to this string More...
 
static void Log (string Text, TStatusCallbackProcedure ACustomStatusCallbackProcedure=null)
 Logs a message. Output goes to both Screen and Logfile and - if a callback has been set up with SetStatusBarProcedure or gets passed in with ACustomStatusCallbackProcedure - to a Status Bar of a Form, too. More...
 
static void LogAtLevel (Int32 Level, string Text)
 Log if level is this high More...
 
static void LogAtLevel (Int32 ALevel, string AText, TLoggingType ALoggingType)
 Log if level is this high. Output destination can be selected with the Loggingtype flag. More...
 
static void Log (string Text, TLoggingType ALoggingType, TStatusCallbackProcedure ACustomStatusCallbackProcedure=null)
 Logs a message. Output destination can be selected with the Loggingtype flag. More...
 
static String StackTraceToText (StackTrace st)
 
static void LogStackTrace (TLoggingType ALoggingtype=TLoggingType.ToConsole|TLoggingType.ToLogfile)
 log the current stack trace More...
 
static void LogException (Exception AEx, String AMethodSignature="")
 Logs a number of messages in one go. Output goes to both Screen and Logfile. More...
 
static void Log (ArrayList aList, bool isException)
 Logs a number of messages in one go. Output goes to both Screen and Logfile. More...
 
static void Log (ArrayList aList, bool isException, TLoggingType Loggingtype)
 Logs a number of messages in one go. Output destination can be selected with the Loggingtype flag. More...
 
static void LogDataTable (DataTable DT)
 Writes the contents of a DataTable to the log file. Useful to have this available for debugging. More...
 

Static Public Attributes

const int DEBUGLEVEL_TRACE = 10
 the debuglevel that is required for stacktrace to be printed; this is related to the mono bug described in the code More...
 
const int DEBUGLEVEL_REPORTING = 5
 the debuglevel that is required for saving some detailed log files for the reporting More...
 
const int DEBUGLEVEL_COORDINATED_DB_ACCESS = 3
 the debuglevel that is required for saving some detailed log files for the co-ordinated DB Access. More...
 
const string LOG_PREFIX_INFO = "INFO: "
 Prefix that can be used for logging messages that are purely informational. More...
 
const string LOG_PREFIX_WARNING = "WARNING: "
 Prefix that can be used for logging messages that are warnings. More...
 
const string LOG_PREFIX_ERROR = "ERROR: "
 Prefix that can be used for logging messages that are errors. More...
 
static int DebugLevel = 0
 some log messages will be only displayed at a certain DebugLevel More...
 
const string DEFAULTUSERNAMEPREFIX = "MiB"
 this is the default prefix for the username More...
 

Properties

static int DL [get]
 DL is a abbreviated synonym for DebugLevel (more convenient) More...
 
static bool NoLoggingToConsoleError [get, set]
 No logging of messages to Console.Error? Set this to true if the PetraServer runs as a Windows Service to prevent Bug #5846! More...
 
static string UserNamePrefix [get, set]
 property for the prefix that describes the More...
 

Detailed Description

The TLogging class provides general logging functionality. Logging output can currently go to the Console, to a file or to both at the same time.

Constructor & Destructor Documentation

◆ TLogging() [1/2]

Ict.Common.TLogging.TLogging ( )
inline

Creates a Console-only logger.

◆ TLogging() [2/2]

Ict.Common.TLogging.TLogging ( String  AFileName,
bool  ASuppressDateAndTime = false 
)
inline

Creates a logger that can log both to Console or file.

Parameters
AFileNameFile to which the output should be written if logging to the logfile is requested.
ASuppressDateAndTimeSet to true to suppress the logging of date and time in log files (default= false).

Member Function Documentation

◆ CanWriteLogFile()

bool Ict.Common.TLogging.CanWriteLogFile ( out String  ALogFileMsg)
inline

Parameters
ALogFileMsg
Returns

◆ GetConsoleLog()

static String Ict.Common.TLogging.GetConsoleLog ( )
inlinestatic

Gets the current console log text. Throws an exception if the console text is being written to a console. You should call SendConsoleOutputToString to send output to this string

Returns

◆ GetLogFileName()

static String Ict.Common.TLogging.GetLogFileName ( )
inlinestatic

returns the name of the current log file

Returns
the path of the current log file

◆ Log() [1/4]

static void Ict.Common.TLogging.Log ( ArrayList  aList,
bool  isException 
)
inlinestatic

Logs a number of messages in one go. Output goes to both Screen and Logfile.

Parameters
aListAn ArrayList containing a number of Log messages
isExceptionIf set to TRUE, an information which states that all following Log messages are Exceptions is written before the Log messages are logged.
Returns
void

◆ Log() [2/4]

static void Ict.Common.TLogging.Log ( ArrayList  aList,
bool  isException,
TLoggingType  Loggingtype 
)
inlinestatic

Logs a number of messages in one go. Output destination can be selected with the Loggingtype flag.

Parameters
aListAn ArrayList containing a number of Log messages
isExceptionIf set to TRUE, an information which states that all following Log messages are Exceptions is written before the Log messages are logged.
Loggingtypelogging destination (eg. console, logfile etc)
Returns
void

◆ Log() [3/4]

static void Ict.Common.TLogging.Log ( string  Text,
TLoggingType  ALoggingType,
TStatusCallbackProcedure  ACustomStatusCallbackProcedure = null 
)
inlinestatic

Logs a message. Output destination can be selected with the Loggingtype flag.

Parameters
TextLog message
ALoggingTypeDetermines the output destination. Note: More than one output destination can be chosen!
ACustomStatusCallbackProcedureOptional instance of a custom callback procedure for writing to the StatusBar of a Form (default = null).

◆ Log() [4/4]

static void Ict.Common.TLogging.Log ( string  Text,
TStatusCallbackProcedure  ACustomStatusCallbackProcedure = null 
)
inlinestatic

Logs a message. Output goes to both Screen and Logfile and - if a callback has been set up with SetStatusBarProcedure or gets passed in with ACustomStatusCallbackProcedure - to a Status Bar of a Form, too.

Parameters
TextLog message
ACustomStatusCallbackProcedureOptional instance of a custom callback procedure for writing to the StatusBar of a Form (default = null).

◆ LogAtLevel() [1/2]

static void Ict.Common.TLogging.LogAtLevel ( Int32  ALevel,
string  AText,
TLoggingType  ALoggingType 
)
inlinestatic

Log if level is this high. Output destination can be selected with the Loggingtype flag.

Parameters
ALevel
AText
ALoggingType

◆ LogAtLevel() [2/2]

static void Ict.Common.TLogging.LogAtLevel ( Int32  Level,
string  Text 
)
inlinestatic

Log if level is this high

Parameters
Level
Text

◆ LogDataTable()

static void Ict.Common.TLogging.LogDataTable ( DataTable  DT)
inlinestatic

Writes the contents of a DataTable to the log file. Useful to have this available for debugging.

Parameters
DT

◆ LogException()

static void Ict.Common.TLogging.LogException ( Exception  AEx,
String  AMethodSignature = "" 
)
inlinestatic

Logs a number of messages in one go. Output goes to both Screen and Logfile.

Parameters
AExThe exception to log
AMethodSignatureThe exception to log
Returns
void

◆ LogStackTrace()

static void Ict.Common.TLogging.LogStackTrace ( TLoggingType  ALoggingtype = TLoggingType.ToConsole | TLoggingType.ToLogfile)
inlinestatic

log the current stack trace

Parameters
ALoggingtypedestination of logging

◆ ResetStaticVariables()

static void Ict.Common.TLogging.ResetStaticVariables ( )
inlinestatic

reset the static variables for each Web Request call.

◆ SendConsoleOutputToString()

static void Ict.Common.TLogging.SendConsoleOutputToString ( TLogNewMessageCallback  ANewMessageCallback)
inlinestatic

Call this method on Windows Forms apps to send the 'console' output to a dynamic string

◆ SetContext()

static void Ict.Common.TLogging.SetContext ( String  context)
inlinestatic

Set the context of the program situation. It is displayed in the next log messages.

Parameters
contextThis will be displayed in the following calls to Log; can be reset with an empty string
Returns
void

◆ SetStatusBarProcedure()

static void Ict.Common.TLogging.SetStatusBarProcedure ( TStatusCallbackProcedure  callbackfn)
inlinestatic

This sets the procedure that is called with the text as an parameter. It can be used to update a status bar.

Returns
void

◆ StackTraceToText()

static String Ict.Common.TLogging.StackTraceToText ( StackTrace  st)
inlinestatic

Parameters
st
Returns

◆ TLogNewMessageCallback()

delegate void Ict.Common.TLogging.TLogNewMessageCallback ( )

his is used for Windows Forms logging

◆ TStatusCallbackProcedure()

delegate void Ict.Common.TLogging.TStatusCallbackProcedure ( string  msg)

this is used for statusbar updates

Member Data Documentation

◆ DebugLevel

int Ict.Common.TLogging.DebugLevel = 0
static

some log messages will be only displayed at a certain DebugLevel

◆ DEBUGLEVEL_COORDINATED_DB_ACCESS

const int Ict.Common.TLogging.DEBUGLEVEL_COORDINATED_DB_ACCESS = 3
static

the debuglevel that is required for saving some detailed log files for the co-ordinated DB Access.

◆ DEBUGLEVEL_REPORTING

const int Ict.Common.TLogging.DEBUGLEVEL_REPORTING = 5
static

the debuglevel that is required for saving some detailed log files for the reporting

◆ DEBUGLEVEL_TRACE

const int Ict.Common.TLogging.DEBUGLEVEL_TRACE = 10
static

the debuglevel that is required for stacktrace to be printed; this is related to the mono bug described in the code

◆ DEFAULTUSERNAMEPREFIX

const string Ict.Common.TLogging.DEFAULTUSERNAMEPREFIX = "MiB"
static

this is the default prefix for the username

◆ LOG_PREFIX_ERROR

const string Ict.Common.TLogging.LOG_PREFIX_ERROR = "ERROR: "
static

Prefix that can be used for logging messages that are errors.

You can prefix any string that you want to be written to the log with this. (The prefix is not translatable.)

◆ LOG_PREFIX_INFO

const string Ict.Common.TLogging.LOG_PREFIX_INFO = "INFO: "
static

Prefix that can be used for logging messages that are purely informational.

You can prefix any string that you want to be written to the log with this. (The prefix is not translatable.)

◆ LOG_PREFIX_WARNING

const string Ict.Common.TLogging.LOG_PREFIX_WARNING = "WARNING: "
static

Prefix that can be used for logging messages that are warnings.

You can prefix any string that you want to be written to the log with this. (The prefix is not translatable.)

Property Documentation

◆ DL

int Ict.Common.TLogging.DL
staticget

DL is a abbreviated synonym for DebugLevel (more convenient)

◆ NoLoggingToConsoleError

bool Ict.Common.TLogging.NoLoggingToConsoleError
staticgetset

No logging of messages to Console.Error? Set this to true if the PetraServer runs as a Windows Service to prevent Bug #5846!

◆ UserNamePrefix

string Ict.Common.TLogging.UserNamePrefix
staticgetset

property for the prefix that describes the


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