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>
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 NString & | GetName () const |
const NString & | GetTypeName () 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 () |
defined(ALIB_DOX) | |
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 |
Thread * | GetOwner () const |
lang::Safeness | GetSafeness () const |
bool | IsOwnedByCurrentThread () const |
ALIB_API void | Release () |
defined(ALIB_DOX) | |
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 |
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.
|
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 81 of file logger.hpp.
time::Ticks TimeOfCreation |
The creation time of the Logger.
Definition at line 100 of file logger.hpp.
time::Ticks TimeOfLastLog |
Timestamp of the last log operation.
Definition at line 103 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 87 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 141 of file logger.hpp.
|
inlinevirtual |
|
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 TextLogger.
Definition at line 173 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 184 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 191 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.