ALib C++ Library
by
Library Version:
2402 R1
Documentation generated by
Loading...
Searching...
No Matches
home
dev
A-Worx
ALib
src
alib
alox
loggers
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)
13
#include "
alib/alox/detail/textlogger/plaintextlogger.hpp
"
14
#endif
15
16
#if !defined (HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM)
17
#include "
alib/compatibility/std_strings_iostream.hpp
"
18
#endif
19
20
21
namespace
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
**************************************************************************************************/
28
namespace
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
**************************************************************************************************/
37
class
ConsoleLogger
:
public
detail::textlogger::PlainTextLogger
38
{
39
protected
:
40
/** The encapsulated output stream. */
41
StringWriter
writer
;
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
******************************************************************************************/
71
ALIB_API
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
******************************************************************************************/
82
ALIB_API
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.
98
using
ConsoleLogger
=
lox::loggers::ConsoleLogger
;
99
100
}
// namespace [alib]
101
102
#endif
// HPP_ALOX_CONSOLE_LOGGER
alib::lox::detail::textlogger::PlainTextLogger
Definition
plaintextlogger.hpp:28
alib::lox::detail::textlogger::PlainTextLogger::PlainTextLogger
PlainTextLogger(const NString &name, const NString &typeName, bool pUsesStdStreams)
Definition
plaintextlogger.hpp:54
alib::lox::loggers::ConsoleLogger
Definition
consolelogger.hpp:38
alib::lox::loggers::ConsoleLogger::notifyMultiLineOp
virtual void notifyMultiLineOp(lang::Phase) override
Definition
consolelogger.hpp:90
alib::lox::loggers::ConsoleLogger::~ConsoleLogger
virtual ~ConsoleLogger() override
Definition
consolelogger.hpp:59
alib::lox::loggers::ConsoleLogger::writer
StringWriter writer
Definition
consolelogger.hpp:41
alib::lox::loggers::ConsoleLogger::ConsoleLogger
ConsoleLogger(const NString &name=nullptr)
Definition
consolelogger.hpp:51
alib::lox::loggers::ConsoleLogger::logSubstring
virtual ALIB_API integer logSubstring(const String &buffer, integer start, integer length) override
Definition
consolelogger.cpp:25
alib::lox::loggers::ConsoleLogger::notifyLogOp
virtual ALIB_API bool notifyLogOp(lang::Phase phase) override
Definition
consolelogger.cpp:18
alib::strings::TString< nchar >
alib::strings::compatibility::std::StringWriter
Definition
std_strings_iostream.hpp:189
ALIB_API
#define ALIB_API
Definition
alib.hpp:538
alib::lang::Phase
Phase
Definition
commonenumdefs.hpp:139
alib
Definition
alib.cpp:57
alib::integer
lang::integer integer
Type alias in namespace alib.
Definition
integers.hpp:286
plaintextlogger.hpp
std_strings_iostream.hpp