ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lox::textlogger::PlainTextLogger Class Referenceabstract

Description:

A text logger that either removes or ignores (just writes through) ALox ESC sequences. Implements abstract method logText and introduces two new abstract methods logPlainTextPart and notifyPlainTextLogOp.

Definition at line 15 of file plaintextlogger.inl.

Inheritance diagram for alib::lox::textlogger::PlainTextLogger:
alib::lox::textlogger::TextLogger alib::lox::detail::Logger alib::threads::RecursiveLock alib::lang::DbgCriticalSections::AssociatedLock alib::lox::loggers::ConsoleLogger alib::lox::loggers::MemoryLogger alib::lox::loggers::TextFileLogger alib::lox::loggers::VStudioLogger

Public Field Index:

bool PruneESCSequences =true
Public Field Index: inherited from alib::lox::textlogger::TextLogger
ObjectConverterConverter = nullptr
TickConverter DateConverter
bool FormatWarningOnce =false
Public Field Index: inherited from alib::lox::detail::Logger
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 alib::threads::RecursiveLock
DbgLockAsserter Dbg
 The debug tool instance.

Protected Method Index:

 PlainTextLogger (const NString &name, const NString &typeName)
virtual ~PlainTextLogger () override
 Destructs a MemoryLogger.
virtual integer logPlainTextPart (const String &buffer, integer start, integer length)=0
virtual void logText (detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber, bool isRecursion) override
virtual bool notifyPlainTextLogOp (lang::Phase phase)=0
Protected Method Index: inherited from alib::lox::textlogger::TextLogger
 TextLogger (const NString &pName, const NString &typeName)
virtual void notifyMultiLineOp (lang::Phase phase)=0
virtual void processVariable (const NString &domainPath, Verbosity verbosity, detail::ScopeInfo &scope, AString &dest, Substring &variable)
virtual void writeMetaInfo (AString &buffer, detail::Domain &domain, Verbosity verbosity, detail::ScopeInfo &scope)
virtual void writeTimeDiff (AString &buffer, int64_t diffNanos)
Protected Method Index: inherited from alib::lox::detail::Logger
 Logger (const NString &name, const NString &typeName)

Additional Inherited Members

Public Method Index: inherited from alib::lox::textlogger::TextLogger
virtual ~TextLogger () override
 Destructs a TextLogger.
virtual void AcknowledgeLox (detail::LoxImpl *lox, lang::ContainerOp op) override
virtual void ClearReplacements ()
 Removes all pairs of searched strings and their replacement value.
FormatAutoSizesGetAutoSizes ()
FormatDateTimeGetFormatDate ()
FormatMetaInfoGetFormatMetaInfo ()
FormatMultiLineGetFormatMultiLine ()
FormatOtherGetFormatOther ()
FormatTimeDiffGetFormatTimeDiff ()
ReplacementsGetReplacements ()
virtual void Log (detail::Domain &domain, Verbosity verbosity, BoxesMA &logables, detail::ScopeInfo &scope) override
virtual void ResetAutoSizes ()
virtual void SetReplacement (const String &searched, const String &replacement)
Public Method Index: inherited from alib::lox::detail::Logger
virtual ~Logger () override
 Destructs a logger.
const NStringGetName () const
const NStringGetTypeName () const
bool SetVerbosityExport (Lox *lox, bool value, Priority priority=Priority::Standard)
Public Method Index: inherited from alib::threads::RecursiveLock
void AcquireRecursive (ALIB_DBG_TAKE_CI)
virtual bool DCSIsAcquired () const override
virtual bool DCSIsSharedAcquired () const override
void ReleaseRecursive (ALIB_DBG_TAKE_CI)
bool TryAcquire (ALIB_DBG_TAKE_CI)
Public Method Index: inherited from alib::lang::DbgCriticalSections::AssociatedLock
virtual ~AssociatedLock ()
 Virtual Destructor.
Protected Field Index: inherited from alib::lox::textlogger::TextLogger
strings::util::CalendarDateTime callerDateTime
AString logBuf
 The internal log Buffer.
AString msgBuf
 The buffer for converting the logables.
Variable varFormatAutoSizes
Variable varFormatDateTime
Variable varFormatMetaInfo
Variable varFormatMultiLine
Variable varFormatOther
Variable varFormatTimeDiff
Variable varReplacements
Protected Field Index: inherited from alib::lox::detail::Logger
NString32 Name
NString32 TypeName
Protected Field Index: inherited from alib::threads::RecursiveLock
std::recursive_mutex mutex

Field Details:

◆ PruneESCSequences

bool alib::lox::textlogger::PlainTextLogger::PruneESCSequences =true

If this field is set to true (the default), all ESC color and style codes get removed when logging into this Logger. ESC::TAB is processed.

It might be useful to set this to false, e.g., in the case, the contents of the Logger are (later) written into a different logger (e.g., as a multi-line message) which is capable of interpreting the escape sequences of class ESC.

Definition at line 27 of file plaintextlogger.inl.

Constructor(s) / Destructor Details:

◆ PlainTextLogger()

alib::lox::textlogger::PlainTextLogger::PlainTextLogger ( const NString & name,
const NString & typeName )
inlineexplicitprotected

Creates a PlainTextLogger

Parameters
nameThe name of the Logger. If empty, it defaults to the type name.
typeNameThe type of the Logger.

Definition at line 36 of file plaintextlogger.inl.

◆ ~PlainTextLogger()

virtual alib::lox::textlogger::PlainTextLogger::~PlainTextLogger ( )
inlineoverrideprotectedvirtual

Destructs a MemoryLogger.

Definition at line 40 of file plaintextlogger.inl.

Method Details:

◆ logPlainTextPart()

virtual integer alib::lox::textlogger::PlainTextLogger::logPlainTextPart ( const String & buffer,
integer start,
integer length )
protectedpure virtual

Abstract method to be implemented by descendants. Has to write the given region of the given string to the destination. Has to return the number of characters written, which might be different from the region length requested, e.g., in case of character set conversions.

If an error occurs, -1 can be returned to indicate that the current log should be aborted. In this case, no invocation of notifyPlainTextLogOp(Phase::End) will be performed.

Parameters
bufferThe string to write a portion of.
startThe start of the portion in buffer to write out.
lengthThe length of the portion in buffer to write out.
Returns
The number of characters written, -1 on error.

Implemented in alib::lox::loggers::ConsoleLogger, alib::lox::loggers::MemoryLogger, alib::lox::loggers::TextFileLogger, and alib::lox::loggers::VStudioLogger.

◆ logText()

void PlainTextLogger::logText ( detail::Domain & domain,
Verbosity verbosity,
AString & msg,
detail::ScopeInfo & scope,
int lineNumber,
bool isRecursion )
overrideprotectedvirtual

The implementation of the abstract method of parent class TextLogger. Loops over the log text, removes or ignores ESC sequences (all but ESC.TAB) and invokes abstract methods of descendants as follows:

Parameters
domainThe Log Domain.
verbosityThe verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only.
msgThe log message.
scopeInformation about the scope of the Log Statement..
lineNumberThe line number of a multi-line message, starting with 0. For single line messages this is -1.
isRecursionIf true, a recursive logging operation was detected. A logger might use this information, for example, to prevent recursive acquisitions of resources.

Implements alib::lox::textlogger::TextLogger.

Definition at line 47 of file plaintextlogger.cpp.

◆ notifyPlainTextLogOp()

virtual bool alib::lox::textlogger::PlainTextLogger::notifyPlainTextLogOp ( lang::Phase phase)
protectedpure virtual

Abstract method to be implemented by descendants. This method is called when a new log message is started. It is called exactly once before a series of logPlainTextPart calls and exactly once after such series. If either the start or one of the calls to logPlainTextPart returns a negative number, the second invocation that would indicate the end of a log message is omitted.

Implementing this method allows the acquisition of system resources (e.g., opening a file).

Parameters
phaseIndicates the beginning or end of a log line.
Returns
If false is returned, the log line is aborted without an invocation of notifyPlainTextLogOp(Phase::End).

Implemented in alib::lox::loggers::ConsoleLogger, alib::lox::loggers::MemoryLogger, alib::lox::loggers::TextFileLogger, and alib::lox::loggers::VStudioLogger.


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