ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
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 41 of file windowsconsolelogger.hpp.

#include <windowsconsolelogger.hpp>

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

Public Field Index:

textlogger::ColorfulLoggerParameters CFP
 
UINT CodePage =65001
 
- Public Field Index: inherited from TextLogger
ObjectConverterConverter = nullptr
 
TickConverter DateConverter
 
bool FormatWarningOnce = false
 
- Public Field Index: inherited from 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 RecursiveLock
DbgLockAsserter Dbg
 The debug tool instance.
 

Public Method Index:

ALIB_API WindowsConsoleLogger (const NString &name=nullptr)
 
virtual ~WindowsConsoleLogger ()
 Destructs a WindowsConsoleLogger.
 
- Public Method Index: inherited from TextLogger
virtual ALIB_API ~TextLogger () override
 Destructs a TextLogger.
 
virtual ALIB_API void ClearReplacements ()
 Removes all pairs of searched strings and their replacement value.
 
FormatAutoSizesGetAutoSizes ()
 
FormatDateTimeGetFormatDate ()
 
FormatMetaInfoGetFormatMetaInfo ()
 
FormatMultiLineGetFormatMultiLine ()
 
FormatOtherGetFormatOther ()
 
FormatTimeDiffGetFormatTimeDiff ()
 
ReplacementsGetReplacements ()
 
virtual ALIB_API void Log (detail::Domain &domain, Verbosity verbosity, BoxesMA &logables, detail::ScopeInfo &scope) override
 
virtual ALIB_API void ResetAutoSizes ()
 
virtual ALIB_API void SetReplacement (const String &searched, const String &replacement)
 
- Public Method Index: inherited from Logger
virtual ~Logger () override
 Destructs a logger.
 
const NStringGetName () const
 
const NStringGetTypeName () const
 
- 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:

WORD originalConsoleAttributes
 The attributes that were set on the windows console at the time this object was created.
 
- Protected Field Index: inherited from TextLogger
lang::system::CalendarDateTime callerDateTime
 
AString logBuf
 The internal log Buffer.
 
AString msgBuf
 The buffers for converting the logables.
 
bool usesStdStreams
 
Variable varFormatAutoSizes
 
Variable varFormatDateTime
 
Variable varFormatMetaInfo
 
Variable varFormatMultiLine
 
Variable varFormatOther
 
Variable varFormatTimeDiff
 
Variable varReplacements
 
- Protected Field Index: inherited from Logger
NString32 Name
 
NString32 TypeName
 
- Protected Field Index: inherited from RecursiveLock
std::recursive_mutex mutex
 

Protected Method Index:

virtual ALIB_API void AcknowledgeLox (detail::LoxImpl *lox, lang::ContainerOp op) override
 
virtual ALIB_API void logText (detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber)
 
virtual ALIB_API void notifyMultiLineOp (lang::Phase)
 Empty implementation, not needed for this class.
 
- Protected Method Index: inherited from TextLogger
ALIB_API TextLogger (const NString &pName, const NString &typeName, bool pUsesStdStreams)
 
virtual ALIB_API void processVariable (const NString &domainPath, Verbosity verbosity, detail::ScopeInfo &scope, AString &dest, Substring &variable)
 
virtual ALIB_API void writeMetaInfo (AString &buffer, detail::Domain &domain, Verbosity verbosity, detail::ScopeInfo &scope)
 
virtual ALIB_API void writeTimeDiff (AString &buffer, int64_t diffNanos)
 
- Protected Method Index: inherited from Logger
 Logger (const NString &name, const NString &typeName)
 

Field Details:

◆ CFP

◆ CodePage

UINT 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 65 of file windowsconsolelogger.hpp.

◆ originalConsoleAttributes

WORD originalConsoleAttributes
protected

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

Definition at line 48 of file windowsconsolelogger.hpp.

Constructor(s) / Destructor Details:

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

◆ ~WindowsConsoleLogger()

virtual ~WindowsConsoleLogger ( )
inlinevirtual

Destructs a WindowsConsoleLogger.

Definition at line 85 of file windowsconsolelogger.hpp.

Method Details:

◆ AcknowledgeLox()

void 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 TextLogger.

Definition at line 76 of file windowsconsolelogger.cpp.

Here is the call graph for this function:

◆ logText()

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

Implements TextLogger.

Definition at line 115 of file windowsconsolelogger.cpp.

Here is the call graph for this function:

◆ notifyMultiLineOp()

virtual ALIB_API void notifyMultiLineOp ( lang::Phase )
inlineprotectedvirtual

Empty implementation, not needed for this class.

Implements TextLogger.

Definition at line 116 of file windowsconsolelogger.hpp.


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