ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
No Matches
Logger Class Referenceabstract


This is central class of the ALox logging implementation. It is not recommended to use this class directly for logging. Instead, use the simple and convenient static interface class Log or, for release logging and other more complex operations use a Lox instance. The class is abstract. To implement an own log stream, derive a new Logger class and implement the abstract method Log.


class Lox

Definition at line 60 of file logger.hpp.

#include <logger.hpp>

Inheritance diagram for Logger:
Collaboration diagram for Logger:

Public Field Index:

integer CntLogs =0
time::Ticks TimeOfCreation
time::Ticks TimeOfLastLog
- Public Field Index: inherited from ThreadLock
NCString DbgOwnerFile =nullptr
NCString DbgOwnerFunc =nullptr
int DbgOwnerLine
uint16_t DbgRecursionWarningThreshold =10
integer DbgWarningAfterWaitTimeInMillis =2000L

Public Method Index:

virtual ~Logger ()
const NStringGetName () const
const NStringGetTypeName () const
virtual void Log (Domain &dom, Verbosity verbosity, Boxes &logables, ScopeInfo &scope)=0
- Public Method Index: inherited from SmartLock
 SmartLock ()
void Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
ALIB_API int AddAcquirer (ThreadLock *newAcquirer)
ALIB_API int CntAcquirers ()
ALIB_API void Release ()
ALIB_API int RemoveAcquirer (ThreadLock *acquirer)
- Public Method Index: inherited from ThreadLock
ALIB_API ThreadLock (lang::Safeness safeness=lang::Safeness::Safe)
ALIB_API ~ThreadLock ()
ALIB_API void Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
int CountAcquirements () const
ThreadGetOwner () const
lang::Safeness GetSafeness () const
bool IsOwnedByCurrentThread () const
ALIB_API void Release ()
ALIB_API void SetSafeness (lang::Safeness safeness)
bool WillRelease () const

Additional Inherited Members

- Public Static Field Index: inherited from SmartLock
static ALIB_API SmartLock StdOutputStreams

Field Details:

◆ CntLogs

integer CntLogs =0

The number of logs actually performed so far. In a text logger this is similar to the line number, despite the fact that a single log call can produce more than one line.

Definition at line 97 of file logger.hpp.

◆ Name

NString32 Name

The name of the Logger. Used as a reference to a logger. All loggers attached to a Lox have to differ in their names. If no name is specified with the constructor, the name will by the same as TypeName.

Definition at line 81 of file logger.hpp.

◆ TimeOfCreation

time::Ticks TimeOfCreation

The creation time of the Logger.

Definition at line 100 of file logger.hpp.

◆ TimeOfLastLog

time::Ticks TimeOfLastLog

Timestamp of the last log operation.

Definition at line 103 of file logger.hpp.

◆ TypeName

NString32 TypeName

The type name of the Logger. This is set by the derived class similar to the class name.

Definition at line 87 of file logger.hpp.

Constructor(s) / Destructor Details::

◆ Logger()

Logger ( const NString & name,
const NString & typeName )

Constructs a logger. This constructor is protected because this class is abstract.

Note: This constructor is implemented in the header and annotated as inline. This way, the Log::InitALox call receives the size of classes from the compilation unit that invokes the constructor. If different compile options are set, we have a chance to detect them here.

nameThe name of the Logger. If empty, it defaults to the type name. Will be converted to upper case.
typeNameThe type of the Logger. Will be converted to upper case.

Definition at line 141 of file logger.hpp.

Here is the call graph for this function:

◆ ~Logger()

virtual ~Logger ( )

Destructs a logger

Definition at line 157 of file logger.hpp.

Method Details:

◆ AcknowledgeLox()

virtual void AcknowledgeLox ( LoxImpl * lox,
lang::ContainerOp op )

This method is invoked by class Lox when a logger is added or removed from it. Note, that a logger might be added to multiple Lox objects in parallel.

The default implementation of this method is empty.

loxThe Lox to acknowledge insertion or removal.
opThe operation. Either ContainerOp::Insert or ContainerOp::Remove.

Reimplemented in TextLogger.

Definition at line 173 of file logger.hpp.

◆ GetName()

const NString & GetName ( ) const

Returns the name of this logger. The name has to be unique for all Loggers attached to a Lox.

The loggers name.

Definition at line 184 of file logger.hpp.

◆ GetTypeName()

const NString & GetTypeName ( ) const

Returns the constant type name of this logger. The type name is defined by the class and hence provides a sort of run-time type information.

The loggers type name.

Definition at line 191 of file logger.hpp.

◆ Log()

virtual void Log ( Domain & dom,
Verbosity verbosity,
Boxes & logables,
ScopeInfo & scope )
pure virtual

This is the central method that derived logger classes have to implement to log a message. When it is invoked the Log Domain's Verbosity was already checked against parameter verbosity . The only action to take is to perform the log itself.
Parameter logables contains at least one object, the one provided with the log statement. Other objects that might be included in the list, are Prefix Objects corresponding to the scope .

domThe Log Domain.
verbosityThe verbosity of the message.
logablesThe list of objects to log.
scopeInformation about the scope of the Log Statement..

Implemented in TextLogger.

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