ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
consolelogger.hpp
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/// Copyright 2013-2026 A-Worx GmbH, Germany.
6/// Published under #"mainpage_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 #"alib::lox::ESC;ESC")
22/// are removed and ignored.
23//==================================================================================================
25 protected:
26 /// Allocator used for the #"std::OStreamWriter".
28
29 /// The #"%OStreamWriter" encapsulated in a placeholder. The instance is constructed
30 /// and destructed with #"notifyPlainTextLogOp". With that, synchronized output is
31 /// guaranteed.
33
34 public:
35 /// Creates a ConsoleLogger.
36 /// @param name (Optional) The name of the \e Logger, defaults to "CONSOLE".
37 explicit ConsoleLogger( const NString& name= nullptr )
38 : PlainTextLogger( name, "CONSOLE" )
39 , ma(ALIB_DBG("ConsoleLogger",) 8) {}
40
41 /// Destructs a ConsoleLogger
42 virtual ~ConsoleLogger() override {}
43
44 //################################################################################################
45 // Abstract method implementations
46 //################################################################################################
47 protected:
48 /// Starts/ends log line. Appends a new-line character sequence to previously logged lines.
49 ///
50 /// @param phase Indicates the beginning or end of a log line.
51 /// @return Always returns true.
53 virtual bool notifyPlainTextLogOp( lang::Phase phase ) override;
54
55 /// Writes the given region of the given string to the console.
56 ///
57 /// @param buffer The string to write a portion of.
58 /// @param start The start of the portion in \p{buffer} to write out.
59 /// @param length The length of the portion in \p{buffer} to write out.
60 /// @return The number of characters written, -1 on error.
62 virtual integer logPlainTextPart( const String& buffer,
63 integer start, integer length ) override;
64
65
66 /// Empty implementation, not needed for this class
67 virtual void notifyMultiLineOp( lang::Phase ) override {}
68
69}; // class ConsoleLogger
70
71
72}} // namespace alib[::lox::loggers]
73
74/// Type alias in namespace #"%alib".
76
77} // namespace [alib]
#define ALIB_DLL
#define ALIB_EXPORT
#define ALIB_DBG(...)
virtual 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 #"std::OStreamWriter".
virtual 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)
Phase
Denotes a phase, e.g.,of a transaction.
Definition alox.cpp:14
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
strings::TString< nchar > NString
Type alias in namespace #"%alib".
Definition string.hpp:2174
lang::integer integer
Type alias in namespace #"%alib".
Definition integers.hpp:149
strings::TString< character > String
Type alias in namespace #"%alib".
Definition string.hpp:2165
lox::loggers::ConsoleLogger ConsoleLogger
Type alias in namespace #"%alib".