ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lox::loggers::WindowsConsoleLogger Class Reference

Description:

A logger that logs all messages to the standard output cout. The name of the Logger defaults to "WINDOWS_CONSOLE".

ALox text logger escape sequences (see class ESC) are translated to Windows API calls (SetConsoleTextAttribute) which manipulates colors the text output. There is not 100% match between windows console capabilities and the definitions in ESC. Especially, ESC style attributes are ignored.

Foreground and background colors can be set to be either light/dark or dark/light. This improves the readability of log output a lot and even allows reading if foreground and background colors are the same (they then still differ). However, the right setting for this is dependent on the color scheme of the final output device (window). To manipulate the right setting, see the field CFP and also configuration variable ALOX/CONSOLE_LIGHT_COLORS.

In the method AcknowledgeLox, the default meta info string and color settings are changed to fit this logger.

Note
This class cannot enable the output console (which receives ALox log data) to support the windows API call SetConsoleTextAttribute. The opposite is right: this class should be used only if the output console supports such calls.

Definition at line 36 of file windowsconsolelogger.inl.

Inheritance diagram for alib::lox::loggers::WindowsConsoleLogger:
alib::lox::textlogger::TextLogger alib::lox::detail::Logger alib::threads::RecursiveLock alib::lang::DbgCriticalSections::AssociatedLock

Public Field Index:

textlogger::ColorfulLoggerParameters CFP
UINT CodePage =65001
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.

Public Method Index:

 WindowsConsoleLogger (const NString &name=nullptr)
virtual ~WindowsConsoleLogger ()
 Destructs a WindowsConsoleLogger.
Public Method Index: inherited from alib::lox::textlogger::TextLogger
virtual ~TextLogger () override
 Destructs a TextLogger.
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:

WORD originalConsoleAttributes
 The attributes that were set on the windows console at the time this object was created.
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

Protected Method Index:

virtual void AcknowledgeLox (detail::LoxImpl *lox, lang::ContainerOp op) override
virtual void logText (detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber, bool isRecursion)
virtual void notifyMultiLineOp (lang::Phase)
 Empty implementation, not needed for this class.
Protected Method Index: inherited from alib::lox::textlogger::TextLogger
 TextLogger (const NString &pName, const NString &typeName)
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)

Field Details:

◆ CFP

textlogger::ColorfulLoggerParameters alib::lox::loggers::WindowsConsoleLogger::CFP
See also
CFP.

Definition at line 63 of file windowsconsolelogger.inl.

◆ CodePage

UINT alib::lox::loggers::WindowsConsoleLogger::CodePage =65001

The code page that is used for the console log output. For possible values refer to Microsoft documentation

This defaults to 65001, which is UTF-8 unicode encoding.

This flag can be modified from outside any time. If the value is not equal to 0, the code page of the output console is set before each log output.

The configuration variable ALOX/CODEPAGE is evaluated within the constructor of this class, to allow to modifying the codepage at run-time.

Definition at line 60 of file windowsconsolelogger.inl.

◆ originalConsoleAttributes

WORD alib::lox::loggers::WindowsConsoleLogger::originalConsoleAttributes
protected

The attributes that were set on the windows console at the time this object was created.

Definition at line 43 of file windowsconsolelogger.inl.

Constructor(s) / Destructor Details:

◆ WindowsConsoleLogger()

alib::lox::loggers::WindowsConsoleLogger::WindowsConsoleLogger ( const NString & name = nullptr)
explicit

Creates a WindowsConsoleLogger.

Parameters
name(Optional) The name of the Logger, defaults to "WINDOWS_CONSOLE".

Definition at line 74 of file windowsconsolelogger.cpp.

◆ ~WindowsConsoleLogger()

virtual alib::lox::loggers::WindowsConsoleLogger::~WindowsConsoleLogger ( )
inlinevirtual

Destructs a WindowsConsoleLogger.

Definition at line 76 of file windowsconsolelogger.inl.

Method Details:

◆ AcknowledgeLox()

void alib::lox::loggers::WindowsConsoleLogger::AcknowledgeLox ( detail::LoxImpl * lox,
lang::ContainerOp op )
overrideprotectedvirtual

Invokes parent method. Then reads and interprets configuration variable ALOX/CONSOLE_LIGHT_COLORS. Finally it is checked if variable ALOX/LOGGERNAME/FORMAT has priority of default values, and if yes, such values are overwritten to include ANSI color codes. These color codes are retrieved from resources named "Var_D21A".

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

Reimplemented from alib::lox::textlogger::TextLogger.

Definition at line 88 of file windowsconsolelogger.cpp.

◆ logText()

void alib::lox::loggers::WindowsConsoleLogger::logText ( detail::Domain & domain,
Verbosity verbosity,
AString & msg,
detail::ScopeInfo & scope,
int lineNumber,
bool isRecursion )
protectedvirtual

The implementation of the abstract method of parent class TextLogger. Logs messages to the basic output stream 'cout' and sets windows console colors by invoking corresponding Windows API methods..

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 126 of file windowsconsolelogger.cpp.

◆ notifyMultiLineOp()

virtual void alib::lox::loggers::WindowsConsoleLogger::notifyMultiLineOp ( lang::Phase )
inlineprotectedvirtual

Empty implementation, not needed for this class.

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

Definition at line 107 of file windowsconsolelogger.inl.


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