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