ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Protected Methods | List of all members
PlainTextLogger Class Referenceabstract

#include <plaintextlogger.hpp>

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

Class 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 logSubstring and notifyLogOp.

Definition at line 27 of file plaintextlogger.hpp.

Public Fields

bool PruneESCSequences = true
 
- Public Fields inherited from TextLogger
lib::strings::util::AutoSizes AutoSizes
 
ObjectConverterConverter = nullptr
 
String16 FmtMsgSuffix
 
String64 FmtMultiLineMsgHeadline = A_CHAR("ALox: Multi line message follows: ")
 
String16 FmtMultiLinePrefix = A_CHAR(">> ")
 
String16 FmtMultiLineSuffix = A_CHAR("")
 
textlogger::MetaInfoMetaInfo
 
AString MultiLineDelimiter
 
String16 MultiLineDelimiterRepl = A_CHAR("\\r")
 
int MultiLineMsgMode =2
 
- Public Fields inherited from Logger
integer CntLogs =0
 
lib::time::Ticks TimeOfCreation
 
lib::time::Ticks TimeOfLastLog
 
- Public Fields inherited from ThreadLock
NCString DbgOwnerFile =nullptr
 
NCString DbgOwnerFunc =nullptr
 
int DbgOwnerLine
 
uint16_t DbgRecursionWarningThreshold =10
 
integer DbgWarningAfterWaitTimeInMillis =2000L
 

Protected Methods

 PlainTextLogger (const NString &name, const NString &typeName, bool pUsesStdStreams)
 
virtual ~PlainTextLogger () override
 
virtual integer logSubstring (const String &buffer, integer start, integer length)=0
 
virtual ALIB_API void logText (detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber) override
 
virtual bool notifyLogOp (Phase phase)=0
 
- Protected Methods inherited from TextLogger
ALIB_API TextLogger (const NString &pName, const NString &typeName, bool pUsesStdStreams)
 
virtual void notifyMultiLineOp (Phase phase)=0
 
- Protected Methods inherited from Logger
 Logger (const NString &name, const NString &typeName)
 

Additional Inherited Members

- Public Types inherited from TextLogger
enum  LightColorUsage { Auto, Never, Foreground, Background }
 
- Public Static Fields inherited from SmartLock
static ALIB_API SmartLock StdOutputStreams
 
- Public Methods inherited from TextLogger
virtual ALIB_API ~TextLogger () override
 
virtual ALIB_API void AcknowledgeLox (LoxImpl *lox, ContainerOp op) override
 
virtual ALIB_API void ClearReplacements ()
 
virtual ALIB_API void Log (Domain &domain, Verbosity verbosity, Boxes &logables, ScopeInfo &scope) override
 
virtual ALIB_API void ResetAutoSizes ()
 
virtual ALIB_API void SetReplacement (const String &searched, const String &replacement)
 
- Public Methods inherited from Logger
virtual ~Logger ()
 
const NStringGetName () const
 
const NStringGetTypeName () const
 
- Public Methods 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) More...
 
ALIB_API int RemoveAcquirer (ThreadLock *acquirer)
 
- Public Methods inherited from ThreadLock
ALIB_API ThreadLock (Safeness safeness=Safeness::Safe)
 
ALIB_API ~ThreadLock ()
 
ALIB_API void Acquire (const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
int CountAcquirements () const
 
ThreadGetOwner () const
 
Safeness GetSafeness () const
 
bool IsOwnedByCurrentThread () const
 
ALIB_API void Release ()
 defined(ALIB_DOX) More...
 
ALIB_API void SetSafeness (Safeness safeness)
 
bool WillRelease () const
 
- Protected Fields inherited from TextLogger
AString logBuf
 
AString msgBuf
 
std::vector< AStringreplacements
 
int stdStreamLockRegistrationCounter =0
 
bool usesStdStreams
 
- Protected Fields inherited from Logger
NString32 Name
 
NString32 TypeName
 
- Protected Fields inherited from SmartLock
std::vector< ThreadLock * > acquirers
 
ThreadLockNR lock
 
- Protected Fields inherited from ThreadLock
uint16_t cntAcquirements =0
 
std::mutex mutex
 
std::condition_variable mutexNotifier
 
std::thread::id owner
 
Safeness safeness
 

Constructor & Destructor Documentation

◆ PlainTextLogger()

PlainTextLogger ( const NString name,
const NString typeName,
bool  pUsesStdStreams 
)
inlineexplicitprotected

Creates a PlainTextLogger

Parameters
nameThe name of the Logger. If empty, it defaults to the type name.
typeNameThe type of the Logger.
pUsesStdStreamsDenotes whether this logger writes to the standard output streams.

Definition at line 54 of file plaintextlogger.hpp.

◆ ~PlainTextLogger()

virtual ~PlainTextLogger ( )
inlineoverrideprotectedvirtual

Destructs a MemoryLogger

Definition at line 61 of file plaintextlogger.hpp.

Member Function Documentation

◆ logSubstring()

virtual integer logSubstring ( 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 notifyLogOp(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 TextFileLogger, MemoryLogger, ConsoleLogger, and VStudioLogger.

◆ logText()

void logText ( detail::Domain domain,
Verbosity  verbosity,
AString msg,
detail::ScopeInfo scope,
int  lineNumber 
)
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.

Implements TextLogger.

Definition at line 35 of file plaintextlogger.cpp.

Here is the call graph for this function:

◆ notifyLogOp()

virtual bool notifyLogOp ( 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 logSubstring() calls and exactly once after such series. If either the start or one of the calls to logSubstring returns false, 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 notifyLogOp(Phase::End).

Implemented in TextFileLogger, MemoryLogger, ConsoleLogger, and VStudioLogger.

Member Data Documentation

◆ PruneESCSequences

bool 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 is (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 41 of file plaintextlogger.hpp.


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