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.
Definition at line 41 of file windowsconsolelogger.hpp.
#include <windowsconsolelogger.hpp>
Public Field Index: | |
textlogger::ColorfulLoggerParameters | CFP |
UINT | CodePage =65001 |
Public Field Index: inherited from TextLogger | |
ObjectConverter * | Converter = 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. | |
FormatAutoSizes & | GetAutoSizes () |
FormatDateTime & | GetFormatDate () |
FormatMetaInfo & | GetFormatMetaInfo () |
FormatMultiLine & | GetFormatMultiLine () |
FormatOther & | GetFormatOther () |
FormatTimeDiff & | GetFormatTimeDiff () |
Replacements & | GetReplacements () |
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 NString & | GetName () const |
const NString & | GetTypeName () 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) | |
Definition at line 68 of file windowsconsolelogger.hpp.
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.
|
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.
|
explicit |
Creates a WindowsConsoleLogger.
name | (Optional) The name of the Logger, defaults to "WINDOWS_CONSOLE". |
Definition at line 62 of file windowsconsolelogger.cpp.
|
inlinevirtual |
Destructs a WindowsConsoleLogger.
Definition at line 85 of file windowsconsolelogger.hpp.
|
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"
.
lox | The Lox to acknowledge insertion or removal |
op | The operation. Either ContainerOp::Insert or ContainerOp::Remove. |
Reimplemented from TextLogger.
Definition at line 76 of file windowsconsolelogger.cpp.
|
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..
domain | The Log Domain. |
verbosity | The verbosity. This has been checked to be active already on this stage and is provided to be able to be logged out only. |
msg | The log message. |
scope | Information about the scope of the Log Statement.. |
lineNumber | The 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.
|
inlineprotectedvirtual |
Empty implementation, not needed for this class.
Implements TextLogger.
Definition at line 116 of file windowsconsolelogger.hpp.