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

Description:

This is a very simple file logger for textual log outputs. The file name string provided in the constructor is not verified. The fileName may be changed by simply setting the public member FileName.

In alignment with ALox principles (ALox does not throw!), the logger does not throw i/o exceptions. In debug-compilations, ALib warnings are issued. Recent system io/ errors are stored in public field# LastSystemError. The constructor tries to open/close the file with write permissions. For many applications, it should be enough to check this field after construction and take according actions on failure. Otherwise, errors may periodically be checked by an application (e.g., no space left on device, etc.).

Definition at line 23 of file textfilelogger.inl.

Inheritance diagram for alib::lox::loggers::TextFileLogger:
[legend]
Collaboration diagram for alib::lox::loggers::TextFileLogger:
[legend]

Public Field Index:

alib::AString FileName
 The path and fileName to the log file.
 
SystemErrors LastSystemError = SystemErrors::None
 
- Public Field Index: inherited from alib::lox::textlogger::PlainTextLogger
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.
 

Public Method Index:

ALIB_DLL TextFileLogger (const alib::String &fileName, const alib::NString &loggerName=nullptr)
 
virtual ~TextFileLogger () override
 Destructs a TextFileLogger.
 
- Public Method Index: inherited from alib::lox::textlogger::TextLogger
virtual ALIB_DLL ~TextLogger () override
 Destructs a TextLogger.
 
virtual ALIB_DLL void AcknowledgeLox (detail::LoxImpl *lox, lang::ContainerOp op) override
 
virtual ALIB_DLL void ClearReplacements ()
 Removes all pairs of searched strings and their replacement value.
 
FormatAutoSizesGetAutoSizes ()
 
FormatDateTimeGetFormatDate ()
 
FormatMetaInfoGetFormatMetaInfo ()
 
FormatMultiLineGetFormatMultiLine ()
 
FormatOtherGetFormatOther ()
 
FormatTimeDiffGetFormatTimeDiff ()
 
ReplacementsGetReplacements ()
 
virtual ALIB_DLL void Log (detail::Domain &domain, Verbosity verbosity, BoxesMA &logables, detail::ScopeInfo &scope) override
 
virtual ALIB_DLL void ResetAutoSizes ()
 
virtual ALIB_DLL 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
 
- Public Method Index: inherited from alib::threads::RecursiveLock
 ~RecursiveLock () override
 Destructor. With debug-compilations, asserts that this lock is not acquired.
 
ALIB_DLL void AcquireRecursive (ALIB_DBG_TAKE_CI)
 
virtual ALIB_DLL bool DCSIsAcquired () const override
 
virtual ALIB_DLL bool DCSIsSharedAcquired () const override
 
ALIB_DLL void ReleaseRecursive (ALIB_DBG_TAKE_CI)
 
ALIB_DLL bool TryAcquire (ALIB_DBG_TAKE_CI)
 
- Public Method Index: inherited from alib::lang::DbgCriticalSections::AssociatedLock
virtual ~AssociatedLock ()
 Virtual Destructor.
 

Protected Field Index:

bool currentlyInMultiLineOp = false
 Flag to prevent file open/close operations when multi line text logging is performed.
 
StringWriter writer
 Encapsulates the text file stream in a system dependent way.
 
- Protected Field Index: inherited from alib::lox::textlogger::TextLogger
strings::util::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 alib::lox::detail::Logger
NString32 Name
 
NString32 TypeName
 
- Protected Field Index: inherited from alib::threads::RecursiveLock
std::recursive_mutex mutex
 

Protected Method Index:

ALIB_DLL void closeFile ()
 Closes the file.
 
virtual ALIB_DLL integer logSubstring (const String &buffer, integer start, integer length) override
 
virtual ALIB_DLL bool notifyLogOp (lang::Phase phase) override
 
virtual ALIB_DLL void notifyMultiLineOp (lang::Phase phase) override
 
ALIB_DLL void openFile ()
 Opens the file.
 
- Protected Method Index: inherited from alib::lox::textlogger::PlainTextLogger
 PlainTextLogger (const NString &name, const NString &typeName, bool pUsesStdStreams)
 
virtual ~PlainTextLogger () override
 Destructs a MemoryLogger.
 
virtual ALIB_DLL void logText (detail::Domain &domain, Verbosity verbosity, AString &msg, detail::ScopeInfo &scope, int lineNumber) override
 
- Protected Method Index: inherited from alib::lox::textlogger::TextLogger
ALIB_DLL TextLogger (const NString &pName, const NString &typeName, bool pUsesStdStreams)
 
virtual ALIB_DLL void processVariable (const NString &domainPath, Verbosity verbosity, detail::ScopeInfo &scope, AString &dest, Substring &variable)
 
virtual ALIB_DLL void writeMetaInfo (AString &buffer, detail::Domain &domain, Verbosity verbosity, detail::ScopeInfo &scope)
 
virtual ALIB_DLL void writeTimeDiff (AString &buffer, int64_t diffNanos)
 
- Protected Method Index: inherited from alib::lox::detail::Logger
 Logger (const NString &name, const NString &typeName)
 
virtual void AcknowledgeLox (LoxImpl *lox, lang::ContainerOp op)
 

Field Details:

◆ currentlyInMultiLineOp

bool alib::lox::loggers::TextFileLogger::currentlyInMultiLineOp = false
protected

Flag to prevent file open/close operations when multi line text logging is performed.

Definition at line 34 of file textfilelogger.inl.

◆ FileName

alib::AString alib::lox::loggers::TextFileLogger::FileName

The path and fileName to the log file.

Definition at line 42 of file textfilelogger.inl.

◆ LastSystemError

SystemErrors alib::lox::loggers::TextFileLogger::LastSystemError = SystemErrors::None

Errors that usually indicate i/o problems. With construction of the logger, the file is tried to be opened and closed, which might indicate major problems (permissions, path, etc) with this public field very early.

Definition at line 47 of file textfilelogger.inl.

◆ writer

StringWriter alib::lox::loggers::TextFileLogger::writer
protected

Encapsulates the text file stream in a system dependent way.

Definition at line 31 of file textfilelogger.inl.

Constructor(s) / Destructor Details:

◆ TextFileLogger()

TextFileLogger::TextFileLogger ( const alib::String & fileName,
const alib::NString & loggerName = nullptr )
explicit

Creates a TextFileLogger.

Parameters
fileNameThe filename (potentially including a path) of the output log file.
loggerNameThe name of the Logger. Defaults to "TEXTFILE".

Definition at line 34 of file textfilelogger.cpp.

Here is the call graph for this function:

◆ ~TextFileLogger()

virtual alib::lox::loggers::TextFileLogger::~TextFileLogger ( )
inlineoverridevirtual

Destructs a TextFileLogger.

Definition at line 66 of file textfilelogger.inl.

Method Details:

◆ closeFile()

void TextFileLogger::closeFile ( )
protected

Closes the file.

Definition at line 75 of file textfilelogger.cpp.

◆ logSubstring()

integer TextFileLogger::logSubstring ( const String & buffer,
integer start,
integer length )
overrideprotectedvirtual

Writes the given region of the given string to the console.

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.

Implements alib::lox::textlogger::PlainTextLogger.

Definition at line 118 of file textfilelogger.cpp.

Here is the call graph for this function:

◆ notifyLogOp()

bool TextFileLogger::notifyLogOp ( lang::Phase phase)
overrideprotectedvirtual

Starts/ends log line. Appends a new-line character sequence to previously logged lines.

Parameters
phaseIndicates the beginning or end of a log line.
Returns
Always returns true.

Implements alib::lox::textlogger::PlainTextLogger.

Definition at line 100 of file textfilelogger.cpp.

Here is the call graph for this function:

◆ notifyMultiLineOp()

void TextFileLogger::notifyMultiLineOp ( lang::Phase phase)
overrideprotectedvirtual

Empty implementation, not needed for this class

Parameters
phaseIndicates the beginning or end of a multi-line operation.

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

Definition at line 88 of file textfilelogger.cpp.

Here is the call graph for this function:

◆ openFile()

void TextFileLogger::openFile ( )
protected

Opens the file.

Definition at line 56 of file textfilelogger.cpp.


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