ALib C++ Library
by
Library Version:
2412 R0
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
#ifndef HPP_ALIB_LOX_CONSOLE_LOGGER
9
#define HPP_ALIB_LOX_CONSOLE_LOGGER 1
10
#pragma once
11
#include "
alib/alox/textlogger/plaintextlogger.hpp
"
12
#include "
alib/compatibility/std_strings_iostream.hpp
"
13
14
15
namespace
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
//==================================================================================================
22
namespace
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
//==================================================================================================
31
class
ConsoleLogger
:
public
textlogger::PlainTextLogger
32
{
33
protected
:
34
/// The encapsulated output stream.
35
StringWriter
writer
;
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
//==========================================================================================
65
ALIB_API
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
//==========================================================================================
76
ALIB_API
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.
92
using
ConsoleLogger
=
lox::loggers::ConsoleLogger
;
93
94
}
// namespace [alib]
95
96
#endif
// HPP_ALIB_LOX_CONSOLE_LOGGER
97
alib::lox::loggers::ConsoleLogger
Definition
consolelogger.hpp:32
alib::lox::loggers::ConsoleLogger::notifyMultiLineOp
virtual void notifyMultiLineOp(lang::Phase) override
Empty implementation, not needed for this class.
Definition
consolelogger.hpp:84
alib::lox::loggers::ConsoleLogger::~ConsoleLogger
virtual ~ConsoleLogger() override
Destructs a ConsoleLogger.
Definition
consolelogger.hpp:53
alib::lox::loggers::ConsoleLogger::writer
StringWriter writer
The encapsulated output stream.
Definition
consolelogger.hpp:35
alib::lox::loggers::ConsoleLogger::ConsoleLogger
ConsoleLogger(const NString &name=nullptr)
Definition
consolelogger.hpp:45
alib::lox::loggers::ConsoleLogger::logSubstring
virtual ALIB_API integer logSubstring(const String &buffer, integer start, integer length) override
Definition
consolelogger.cpp:23
alib::lox::loggers::ConsoleLogger::notifyLogOp
virtual ALIB_API bool notifyLogOp(lang::Phase phase) override
Definition
consolelogger.cpp:16
alib::lox::textlogger::PlainTextLogger
Definition
plaintextlogger.hpp:26
alib::lox::textlogger::PlainTextLogger::PlainTextLogger
PlainTextLogger(const NString &name, const NString &typeName, bool pUsesStdStreams)
Definition
plaintextlogger.hpp:50
alib::strings::TString< nchar >
alib::strings::compatibility::std::StringWriter
Definition
std_strings_iostream.hpp:178
ALIB_API
#define ALIB_API
Definition
alib.hpp:639
alib::lang::Phase
Phase
Denotes a phase, e.g.,of a transaction.
Definition
commonenumdefs.hpp:141
alib
Definition
alib.cpp:69
alib::integer
lang::integer integer
Type alias in namespace alib.
Definition
integers.hpp:273
plaintextlogger.hpp
std_strings_iostream.hpp