ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
consolelogger.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of module \alib_alox of the \aliblong.
4///
5/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8ALIB_EXPORT namespace alib { namespace lox {
9//==================================================================================================
10/// This is the C++ namespace for the implementation of <em>logger classes</em> that are provided
11/// by default with <b>%ALox Logging Library</b>.
12///
13/// Developed by A-Worx GmbH and published under Boost Software License.
14//==================================================================================================
15namespace loggers {
16
17//==================================================================================================
18/// A logger that logs all messages to the standard output <em>std::cout</em>.
19/// The name of the \e Logger defaults to "CONSOLE".
20///
21/// \alox text logger escape sequences (see class \ref alib::lox::ESC "ESC")
22/// are removed and ignored.
23//==================================================================================================
25{
26 protected:
27 /// Allocator used for the \alib{strings::compatibility::std;OStreamWriter}.
29
30 /// The \b OStreamWriter encapsulated in a placeholder. The instance is constructed
31 /// and destructed with #notifyPlainTextLogOp. With that, synchronized output is
32 /// guaranteed.
34
35 public:
36 /// Creates a ConsoleLogger.
37 /// @param name (Optional) The name of the \e Logger, defaults to "CONSOLE".
38 explicit ConsoleLogger( const NString& name= nullptr )
39 : PlainTextLogger( name, "CONSOLE" )
40 , ma(ALIB_DBG("ConsoleLogger",) 8) {}
41
42 /// Destructs a ConsoleLogger
43 virtual ~ConsoleLogger() override {}
44
45 //################################################################################################
46 // Abstract method implementations
47 //################################################################################################
48 protected:
49 /// Starts/ends log line. Appends a new-line character sequence to previously logged lines.
50 ///
51 /// @param phase Indicates the beginning or end of a log line.
52 /// @return Always returns true.
54 virtual bool notifyPlainTextLogOp( lang::Phase phase ) override;
55
56 /// Writes the given region of the given string to the console.
57 ///
58 /// @param buffer The string to write a portion of.
59 /// @param start The start of the portion in \p{buffer} to write out.
60 /// @param length The length of the portion in \p{buffer} to write out.
61 /// @return The number of characters written, -1 on error.
63 virtual integer logPlainTextPart( const String& buffer,
64 integer start, integer length ) override;
65
66
67 /// Empty implementation, not needed for this class
68 virtual void notifyMultiLineOp( lang::Phase ) override {}
69
70}; // class ConsoleLogger
71
72
73}} // namespace alib[::lox::loggers]
74
75/// Type alias in namespace \b alib.
77
78} // namespace [alib]
virtual ALIB_DLL integer logPlainTextPart(const String &buffer, integer start, integer length) override
virtual void notifyMultiLineOp(lang::Phase) override
Empty implementation, not needed for this class.
virtual ~ConsoleLogger() override
Destructs a ConsoleLogger.
MonoAllocator ma
Allocator used for the OStreamWriter.
virtual ALIB_DLL bool notifyPlainTextLogOp(lang::Phase phase) override
ConsoleLogger(const NString &name=nullptr)
lang::Placeholder< OStreamWriter< nchar, MonoAllocator, true > > writer
PlainTextLogger(const NString &name, const NString &typeName)
#define ALIB_DLL
Definition alib.inl:503
#define ALIB_EXPORT
Definition alib.inl:497
#define ALIB_DBG(...)
Definition alib.inl:853
Phase
Denotes a phase, e.g.,of a transaction.
lox::loggers::ConsoleLogger ConsoleLogger
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
strings::TString< nchar > NString
Type alias in namespace alib.
Definition string.inl:2198
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189