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.
class Lox
Definition at line 53 of file logger.hpp.
#include <logger.hpp>
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 NString & | GetName () const |
const NString & | GetTypeName () 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) |
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.
|
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.
time::Ticks TimeOfCreation |
The creation time of the Logger.
Definition at line 87 of file logger.hpp.
time::Ticks TimeOfLastLog |
Timestamp of the last log operation.
Definition at line 90 of file logger.hpp.
|
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.
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.
name | The name of the Logger. If empty, it defaults to the type name. Will be converted to upper case. |
typeName | The type of the Logger. Will be converted to upper case. |
Definition at line 128 of file logger.hpp.
|
inlineoverridevirtual |
Destructs a logger.
Definition at line 146 of file logger.hpp.
|
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.
lox | The Lox to acknowledge insertion or removal. |
op | The operation. Either ContainerOp::Insert or ContainerOp::Remove. |
Reimplemented in AnsiLogger, VStudioLogger, WindowsConsoleLogger, and TextLogger.
Definition at line 162 of file logger.hpp.
|
inline |
Returns the name of this logger. The name has to be unique for all Loggers attached to a Lox.
Definition at line 173 of file logger.hpp.
|
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.
Definition at line 180 of file logger.hpp.
|
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.
dom | The Log Domain. |
verbosity | The verbosity of the message. |
logables | The list of objects to log. |
scope | Information about the scope of the Log Statement.. |
Implemented in TextLogger.