ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
Logger Class Referenceabstract

Description:

This is a 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.

Friends

class Lox

Definition at line 53 of file logger.hpp.

#include <logger.hpp>

Inheritance diagram for Logger:
[legend]
Collaboration diagram for Logger:
[legend]

Public Field Index:

integer CntLogs =0
 
time::Ticks TimeOfCreation
 The creation time of the Logger.
 
time::Ticks TimeOfLastLog
 Timestamp of the last log operation.
 
- Public Field Index: inherited from RecursiveLock
DbgLockAsserter Dbg
 The debug tool instance.
 

Public Method Index:

virtual ~Logger () override
 Destructs a logger.
 
const NStringGetName () const
 
const NStringGetTypeName () const
 
virtual void Log (Domain &dom, Verbosity verbosity, BoxesMA &logables, ScopeInfo &scope)=0
 
- Public Method Index: inherited from RecursiveLock
 ~RecursiveLock () override
 Destructor. With debug-compilations, asserts that this lock is not acquired.
 
ALIB_API void AcquireRecursive (ALIB_DBG_TAKE_CI)
 
virtual ALIB_API bool DCSIsAcquired () const override
 
virtual ALIB_API bool DCSIsSharedAcquired () const override
 
ALIB_API void ReleaseRecursive (ALIB_DBG_TAKE_CI)
 
ALIB_API bool TryAcquire (ALIB_DBG_TAKE_CI)
 
- Public Method Index: inherited from DbgCriticalSections::AssociatedLock
virtual ~AssociatedLock ()
 Virtual Destructor.
 

Protected Field Index:

NString32 Name
 
NString32 TypeName
 
- Protected Field Index: inherited from RecursiveLock
std::recursive_mutex mutex
 

Protected Method Index:

 Logger (const NString &name, const NString &typeName)
 
virtual void AcknowledgeLox (LoxImpl *lox, lang::ContainerOp op)
 

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 84 of file logger.hpp.

◆ Name

NString32 Name
protected

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 72 of file logger.hpp.

◆ TimeOfCreation

time::Ticks TimeOfCreation

The creation time of the Logger.

Definition at line 87 of file logger.hpp.

◆ TimeOfLastLog

time::Ticks TimeOfLastLog

Timestamp of the last log operation.

Definition at line 90 of file logger.hpp.

◆ TypeName

NString32 TypeName
protected

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

Definition at line 76 of file logger.hpp.

Constructor(s) / Destructor Details:

◆ Logger()

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

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.

Parameters
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 128 of file logger.hpp.

Here is the call graph for this function:

◆ ~Logger()

virtual ~Logger ( )
inlineoverridevirtual

Destructs a logger.

Definition at line 146 of file logger.hpp.

Method Details:

◆ AcknowledgeLox()

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

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.

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

Reimplemented in AnsiLogger, VStudioLogger, WindowsConsoleLogger, and TextLogger.

Definition at line 162 of file logger.hpp.

◆ GetName()

const NString & GetName ( ) const
inline

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

Returns
The loggers name.

Definition at line 173 of file logger.hpp.

◆ GetTypeName()

const NString & GetTypeName ( ) const
inline

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.

Returns
The loggers type name.

Definition at line 180 of file logger.hpp.

◆ Log()

virtual void Log ( Domain & dom,
Verbosity verbosity,
BoxesMA & 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.

Parameters
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: