siliziumbrain.errorlogger: Types Modinfo Source  

ErrorLogger

This module provides a very simple to use Instance() which creates nicely formatted log-files.

Types Summary

TErrorLogger Error Logger to wirte error files.
TErrorMessage Class for the messages the errorlogger uses.
TLogLevel Class for the loglevels.
TLogMessage Class for the messages the errorlogger uses.

Types

Type TErrorLogger Extends TObject
DescriptionError Logger to wirte error files.
InformationIt allows to have multiple Error-Log files (one for each instance).
It provides an simple way of logging nicely formatted errors.
Methods Summary
__CondVar Private method. Do not use!
__IsFinished Private method. Do not use!
__MessageQueue Private method. Do not use!
__Mutex Private method. Do not use!
__SetCondVar Private method. Do not use!
__SetIsFinished Private method. Do not use!
__SetMessageQueue Private method. Do not use!
__SetMutex Private method. Do not use!
__SetUpdateThread Private method. Do not use!
__UpdateThread Private method. Do not use!
ChangeCurrentErrorLevel Setter for the current error level.
Copy Copies the object.
CurrentErrorLevel Getter for the current error level.
Equals Checks if two objects are equal.
HasFinishedWriting Checks if the logger is still writing logs.
Log_Error Logs an error.
Log_Message Logs a simple message.
Log_NewLine Just logs an empty line.
New Do NOT! use. Constructor.
Functions Summary
Instance Returns the instance of the TErrorLogger class.
Update Updates the error logger.
Method __CondVar:TCondVar()
DescriptionPrivate method. Do not use!
InformationGetter for the cond var (for multithreading).
Method __IsFinished:Byte()
DescriptionPrivate method. Do not use!
InformationGetter for the is finished value.
Method __MessageQueue:TQueue()
DescriptionPrivate method. Do not use!
InformationGetter for the message queue.
Method __Mutex:TMutex()
DescriptionPrivate method. Do not use!
InformationGetter for the mutex (to use multithreading).
Method __SetCondVar(ptcvCondVar:TCondVar)
DescriptionPrivate method. Do not use!
InformationSetter for the cond var.
Method __SetIsFinished(pbIsFinished:Byte)
DescriptionPrivate method. Do not use!
InformationSetter for the is finished value.
Method __SetMessageQueue(ptQueue:TQueue)
DescriptionPrivate method. Do not use!
InformationSetter for the message queue.
Method __SetMutex(ptmMutex:TMutex)
DescriptionPrivate method. Do not use!
InformationSetter for the mutex.
Method __SetUpdateThread(pttUpdateThread:TThread)
DescriptionPrivate method. Do not use!
InformationSetter for the update thread.
Method __UpdateThread:TThread()
DescriptionPrivate method. Do not use!
InformationGetter for the update thread.
Method ChangeCurrentErrorLevel(piNewErrorLevel:Int)
DescriptionSetter for the current error level.
InformationChanges the current error level (#CurrentErrorLevel) to piNewErrorLevel.
Method Copy:TErrorLogger()
DescriptionCopies the object.
InformationHad to been implemented because of TObject.
returns: Just the instance.
Method CurrentErrorLevel:TLogLevel()
DescriptionGetter for the current error level.
InformationThe current error level tells the logger which errors should be logged.
returns: The current error level (#TLogLevel).
Method Equals:Byte(ptoOtherObject:TObject)
DescriptionChecks if two objects are equal.
InformationHad to been implemented because of TObject.
Method HasFinishedWriting:Byte()
DescriptionChecks if the logger is still writing logs.
InformationThis is needed to decide if a programm may end.
You have to wait until this returns true.
Method Log_Error(psMessage:String, psCategory:String, psComesFromFile:String, psFileToWriteIn:String, piLogLevel:Int, poUsedObject:Object = Null)
DescriptionLogs an error.
InformationUse this method to log an error.
psMessage is the error message self.
psCategory is the category to which the error belongs.
psComesFromFile is the filename where the error occurred.
psFileToWriteIn is the path to the file where the error should be written into.
piLogLevel is the error level of the logged error.
poUsedObject can be an object which was used when an error occurred. If it is null, nothing about the object is written.
Method Log_Message(psMessage:String, psCategory:String, psFileToWriteIn:String, piLogLevel:Int)
DescriptionLogs a simple message.
InformationUse this method to log a simple message without many information.
psMessage is the message self.
psCategory is the category to which the message belongs. psFileToWriteIn is the path to the file where the message should be written into.
piLogLevel is the message level(<=> error level) of the logged message.
Method Log_NewLine(psFileToWriteIn:String, piLogLevel:Int)
DescriptionJust logs an empty line.
InformationUse this method if you want to have an empty line.
psFileToWriteIn is the path to the file where the message should be written into.
piLogLevel is the message level(<=> error level) of the logged message.
Method New()
DescriptionDo NOT! use. Constructor.
InformationConstructor for an errorlogger. This should be only used by the class itself.
Function Instance:TErrorLogger()
DescriptionReturns the instance of the TErrorLogger class.
InformationThis is needed because the class is a singleton.
Function Update:Object(ptelLogger:Object)
DescriptionUpdates the error logger.
InformationThis function runs in an own thread.
returns: Nothing.

Type TErrorMessage Extends TObject
DescriptionClass for the messages the errorlogger uses.
InformationThe TErrorLogger uses errormessages to log the errors.
Methods Summary
__SetCategory Private method. Do not use!
__SetComesFromFile Private method. Do not use!
__SetFileToWriteIn Private method. Do not use.
__SetLogLevel Private method. Do not use!
__SetMessage Private method. Do not use!
__SetObjectString Private method. Do not use!
__SetTimeWhenCreated Private method. Do not use!
Category Getter for the category.
ComesFromFile Getter for the filename where the error occurred.
Copy Copies the object.
Equals Checks if two messages are equal.
FileToWriteIn Getter for the path of the destination file.
LogLevel Getter for the loglevel.
Message Getter for the message.
NewLogMessage Constructor.
ObjectString Getter for the object string.
TimeWhenCreated Getter for the time when the message was created.
ToString Returns the message as a string.
Method __SetCategory(psCategory:String)
DescriptionPrivate method. Do not use!
InformationSets the category of the message to psCategory.
Method __SetComesFromFile(psComesFromFile:String)
DescriptionPrivate method. Do not use!
InformationSets the filename where the message comes from to psComesFromFile.
Method __SetFileToWriteIn(psFileToWriteIn:String)
DescriptionPrivate method. Do not use.
InformationSets the path of the destination file to psFileToWriteIn.
Method __SetLogLevel(ptllLogLevel:TLogLevel)
DescriptionPrivate method. Do not use!
InformationSets the loglevel of the message to ptllLogLevel.
Method __SetMessage(psMessage:String)
DescriptionPrivate method. Do not use!
InformationSets the given message to psMessage.
Method __SetObjectString(psObjectString:String)
DescriptionPrivate method. Do not use!
InformationSets the object string to psObjectString.
Method __SetTimeWhenCreated(psTimeWhenCreated:String)
DescriptionPrivate method. Do not use!
InformationSets the time when the message was created to psTimeWhenCreated.
Method Category:String()
DescriptionGetter for the category.
InformationThis method returns the category of the message.
returns: The category of the message.
Method ComesFromFile:String()
DescriptionGetter for the filename where the error occurred.
InformationThis method returns the filename of the file where the error occured, so where the message comes from.
returns: Filename of the file where the message comes from.
Method Copy:TErrorMessage()
DescriptionCopies the object.
InformationHad to been implemented because of TObject.
Method Equals:Byte(ptoOtherObject:TObject)
DescriptionChecks if two messages are equal.
InformationChecks if ptoOtherObject and the message which called this method are equal.
returns: True if equal, otherwise false.
Method FileToWriteIn:String()
DescriptionGetter for the path of the destination file.
InformationThis method returns the path to the file where the message should be written in.
returns: The path of the destination file.
Method LogLevel:TLogLevel()
DescriptionGetter for the loglevel.
InformationThis method returns the loglevel (#TLogLevel) of the message.
returns: The loglevel of the message.
Method Message:String()
DescriptionGetter for the message.
InformationThis method returns the given message.
returns: The given message.
Method NewLogMessage:TErrorMessage(psMessage:String, psCategory:String, psFileToWriteIn:String, psComesFromFile:String, piLogLevel:Int, psObjectString:String = "")
DescriptionConstructor.
InformationCreates a new TErrorMessage.
psMessage is the given message.
psCategory is the category.
psFileToWriteIn is the path of the destination file.
psComesFromFile is the filename of the file message comes from.
piLogLevel is the loglevel.
psObjectString is the string of the used object.
Method ObjectString:String()
DescriptionGetter for the object string.
InformationThis method returns the string of the used object.
returns: The string of the object which was used.
Method TimeWhenCreated:String()
DescriptionGetter for the time when the message was created.
InformationThis method returns the time when the message was created as a string.
returns: The time when the message was created.
Method ToString:String()
DescriptionReturns the message as a string.

Type TLogLevel Extends TObject
DescriptionClass for the loglevels.
InformationThis class is used to specify the seriousness of errors which are logged.
Constants Summary
LOGLEVEL_COUNT , LOGLEVEL_DEBUGGING , LOGLEVEL_FATALONLY , LOGLEVEL_NORMALERRORS
Methods Summary
__SetLevel Private method. Do not use!
Copy Copies the object.
Equals Checks if this loglevel and another Object are equal.
Level Getter for the Level.
NewLogLevel Constructor.
ToString Returns the loglevel as a string.
Const LOGLEVEL_COUNT:Int
DescriptionThe amount of loglevels.
Const LOGLEVEL_DEBUGGING:Int
DescriptionEverything is logged.
Const LOGLEVEL_FATALONLY:Int
DescriptionOnly fatal errors are logged.
Const LOGLEVEL_NORMALERRORS:Int
DescriptionNormal logging. Not only fatal errors but even not everything.
Method __SetLevel(piLevel:Int)
DescriptionPrivate method. Do not use!
InformationSets the level of the loglevel to piLevel.
If the given value is too big or too small, then it adjusted.
Method Copy:TObject()
DescriptionCopies the object.
InformationHad to been implemented because of TObject.
Method Equals:Byte(ptoOtherObject:TObject)
DescriptionChecks if this loglevel and another Object are equal.
InformationChecks if this loglevel and ptoOtherObject are equal.
returns: True if equal, otherwise false.
Method Level:Int()
DescriptionGetter for the Level.
InformationThis method returns the level of the Loglevel.
returns: The level of the loglevel.
Method NewLogLevel:TLogLevel(piLevel:Int)
DescriptionConstructor.
InformationCreates a new TLogLevel and sets its level to piLevel.
Method ToString:String()
DescriptionReturns the loglevel as a string.

Type TLogMessage Extends TErrorMessage
DescriptionClass for the messages the errorlogger uses.
InformationThe TErrorLogger uses logmessages to log simple messages.
Methods Summary
Copy Copies the object.
Equals Checks if two messages are equal.
NewMessage Constructor.
ToString Returns the message as a string.
Method Copy:TErrorMessage()
DescriptionCopies the object.
Method Equals:Byte(ptoOtherObject:TObject)
DescriptionChecks if two messages are equal.
InformationChecks if ptoOtherObject and the message which called this method are equal.
returns: True if equal, otherwise false.
Method NewMessage:TLogMessage(psMessage:String, psCategory:String, psFileToWriteIn:String, piLogLevel:Int)
DescriptionConstructor.
InformationCreates a new TErrorMessage.
psMessage is the given message.
psCategory is the category.
psFileToWriteIn is the path of the destination file.
piLogLevel is the loglevel.
Method ToString:String()
DescriptionReturns the message as a string.

Module Information

Versionv1.20
AuthorM0rgenstern - Siliziumbrain - Kevin Peter Hoffeld
LicensePublic Domain
History v1.0001 March 2012 - Final Release
History v1.1014 July 2012 - MultiThreading and Singleton.
History v1.2015 July 2012 - Simple messages can now be logged if only information are needed but no error occured. Also: Fixed the HasFinishedWriting method. Also: Added possibility to log empty lines.