ALib C++ Library
Library Version: 2412 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/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_LOX_CONSOLE_LOGGER
9#define HPP_ALIB_LOX_CONSOLE_LOGGER 1
10#pragma once
13
14
15namespace alib { namespace lox {
16//==================================================================================================
17/// This is the C++ namespace for the implementation of <em>logger classes</em> that are provided
18/// by default with <b>%ALox Logging Library</b>.
19///
20/// Developed by A-Worx GmbH and published under Boost Software License.
21//==================================================================================================
22namespace loggers {
23
24//==================================================================================================
25/// A logger that logs all messages to the standard output <em>cout</em>.
26/// The name of the \e Logger defaults to "CONSOLE".
27///
28/// \alox text logger escape sequences (see class \ref alib::lox::ESC "ESC")
29/// are removed and ignored.
30//==================================================================================================
32{
33 protected:
34 /// The encapsulated output stream.
36
37 // #############################################################################################
38 // Constructor/destructor
39 // #############################################################################################
40 public:
41 //==========================================================================================
42 /// Creates a ConsoleLogger.
43 /// @param name (Optional) The name of the \e Logger, defaults to "CONSOLE".
44 //==========================================================================================
45 explicit ConsoleLogger( const NString& name= nullptr )
46 : PlainTextLogger( name, "CONSOLE", true )
47 {}
48
49
50 //==========================================================================================
51 /// Destructs a ConsoleLogger
52 //==========================================================================================
53 virtual ~ConsoleLogger() override {}
54
55 // #############################################################################################
56 // Abstract method implementations
57 // #############################################################################################
58 protected:
59 //==========================================================================================
60 /// Starts/ends log line. Appends a new-line character sequence to previously logged lines.
61 ///
62 /// @param phase Indicates the beginning or end of a log line.
63 /// @return Always returns true.
64 //==========================================================================================
66 virtual bool notifyLogOp( lang::Phase phase ) override;
67
68 //==========================================================================================
69 /// Writes the given region of the given string to the console.
70 ///
71 /// @param buffer The string to write a portion of.
72 /// @param start The start of the portion in \p{buffer} to write out.
73 /// @param length The length of the portion in \p{buffer} to write out.
74 /// @return The number of characters written, -1 on error.
75 //==========================================================================================
77 virtual integer logSubstring( const String& buffer,
78 integer start, integer length ) override;
79
80
81 //==========================================================================================
82 /// Empty implementation, not needed for this class
83 //==========================================================================================
84 virtual void notifyMultiLineOp( lang::Phase ) override {}
85
86}; // class ConsoleLogger
87
88
89}} // namespace alib[::lox::loggers]
90
91/// Type alias in namespace \b alib.
93
94} // namespace [alib]
95
96#endif // HPP_ALIB_LOX_CONSOLE_LOGGER
97
virtual void notifyMultiLineOp(lang::Phase) override
Empty implementation, not needed for this class.
virtual ~ConsoleLogger() override
Destructs a ConsoleLogger.
StringWriter writer
The encapsulated output stream.
ConsoleLogger(const NString &name=nullptr)
virtual ALIB_API integer logSubstring(const String &buffer, integer start, integer length) override
virtual ALIB_API bool notifyLogOp(lang::Phase phase) override
PlainTextLogger(const NString &name, const NString &typeName, bool pUsesStdStreams)
#define ALIB_API
Definition alib.hpp:639
Phase
Denotes a phase, e.g.,of a transaction.
Definition alib.cpp:69
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273