DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
LoggerTextWriter.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
Extensions/Logging/LoggerTextWriter.h
"
3
#include "
Extensions/Logging/LogManager.h
"
4
#include "
System/Text/TextEncoding.h
"
5
6
namespace
DotNetDupe
{
7
namespace
Extensions
{
8
namespace
Logging
{
9
10
LoggerTextWriter::LoggerTextWriter
(
const
DotNetDupe::System::String
& sCategoryName,
LogLevel
logLevel)
11
: m_pLogger(
LogManager
::GetLogger(sCategoryName)), m_logLevel(logLevel) {
13
}
14
15
LoggerTextWriter::LoggerTextWriter
(
const
DotNetDupe::System::SmartPointer<ILogger>
& pLogger,
LogLevel
logLevel)
16
: m_pLogger(pLogger), m_logLevel(logLevel) {
18
}
19
20
void
LoggerTextWriter::Close
() {
22
Flush
();
23
}
24
25
void
LoggerTextWriter::Dispose
() {
27
Close
();
28
}
29
30
void
LoggerTextWriter::Flush
() {
32
(void)0;
33
}
34
35
System::Text::EncodingPtr
LoggerTextWriter::GetEncoding
()
const
{
37
return
DotNetDupe::System::Text::TextEncoding::UTF8
();
38
}
39
40
void
LoggerTextWriter::Write
(
bool
bValue) {
42
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, bValue));
43
}
44
45
void
LoggerTextWriter::Write
(
char
chValue) {
47
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, chValue));
48
}
49
50
void
LoggerTextWriter::Write
(
const
char
* pValue) {
52
if
(pValue) {
53
Write
(
DotNetDupe::System::String
(pValue));
54
}
55
}
56
57
void
LoggerTextWriter::Write
(
const
DotNetDupe::System::String
& sValue) {
59
if
(!sValue.
IsEmpty
() && !m_pLogger.IsNull()) {
60
m_pLogger->Log(m_logLevel, sValue);
61
}
62
}
63
64
void
LoggerTextWriter::Write
(
int
iValue) {
66
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, iValue));
67
}
68
69
void
LoggerTextWriter::Write
(
long
long
llValue) {
71
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, llValue));
72
}
73
74
void
LoggerTextWriter::Write
(
float
fValue) {
76
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, fValue));
77
}
78
79
void
LoggerTextWriter::Write
(
double
dValue) {
81
Write
(
DotNetDupe::System::String::Format
(
"{0}"
, dValue));
82
}
83
84
void
LoggerTextWriter::WriteLine
() {
86
Write
(
DotNetDupe::System::String
(
""
));
87
}
88
89
void
LoggerTextWriter::WriteLine
(
bool
bValue) {
91
Write
(bValue);
92
}
93
94
void
LoggerTextWriter::WriteLine
(
char
chValue) {
96
Write
(chValue);
97
}
98
99
void
LoggerTextWriter::WriteLine
(
const
char
* pValue) {
101
Write
(pValue);
102
}
103
104
void
LoggerTextWriter::WriteLine
(
const
DotNetDupe::System::String
& sValue) {
106
Write
(sValue);
107
}
108
109
void
LoggerTextWriter::WriteLine
(
int
iValue) {
111
Write
(iValue);
112
}
113
114
void
LoggerTextWriter::WriteLine
(
long
long
llValue) {
116
Write
(llValue);
117
}
118
119
void
LoggerTextWriter::WriteLine
(
float
fValue) {
121
Write
(fValue);
122
}
123
124
void
LoggerTextWriter::WriteLine
(
double
dValue) {
126
Write
(dValue);
127
}
128
129
}
130
}
131
}
LogManager.h
LoggerTextWriter.h
TextEncoding.h
Represents character encodings and code page conversions.
DotNetDupe::Extensions::Logging::LogManager
Central thread-safe static registry and entry point for application logging.
Definition
LogManager.h:18
DotNetDupe::Extensions::Logging::LoggerTextWriter::Dispose
void Dispose() override
Disposes the writer resources.
Definition
LoggerTextWriter.cpp:25
DotNetDupe::Extensions::Logging::LoggerTextWriter::Flush
void Flush() override
Flushes any buffered text to the logger.
Definition
LoggerTextWriter.cpp:30
DotNetDupe::Extensions::Logging::LoggerTextWriter::Close
void Close() override
Closes the writer and flushes buffered content.
Definition
LoggerTextWriter.cpp:20
DotNetDupe::Extensions::Logging::LoggerTextWriter::Write
void Write(bool bValue) override
Writes a boolean value to the logger buffer.
Definition
LoggerTextWriter.cpp:40
DotNetDupe::Extensions::Logging::LoggerTextWriter::LoggerTextWriter
LoggerTextWriter(const DotNetDupe::System::String &sCategoryName="Console", LogLevel logLevel=LogLevel::Information)
Initializes a LoggerTextWriter with category name and log level.
Definition
LoggerTextWriter.cpp:10
DotNetDupe::Extensions::Logging::LoggerTextWriter::WriteLine
void WriteLine() override
Writes a line terminator, emitting the accumulated buffer to the logger.
Definition
LoggerTextWriter.cpp:84
DotNetDupe::Extensions::Logging::LoggerTextWriter::GetEncoding
virtual System::Text::EncodingPtr GetEncoding() const override
Gets the character encoding for text output (UTF-8).
Definition
LoggerTextWriter.cpp:35
DotNetDupe::System::SmartPointer
A unified smart pointer that supports both unique and shared ownership semantics.
Definition
SmartPointer.h:72
DotNetDupe::System::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
DotNetDupe::System::String::IsEmpty
bool IsEmpty() const
Definition
String.cpp:398
DotNetDupe::System::String::Format
static String Format(const char *pFormat, const Arg1 &arg1, const Args &... args)
Definition
String.h:239
DotNetDupe::System::Text::TextEncoding::UTF8
static EncodingPtr UTF8()
Gets an encoding for the UTF-8 format.
Definition
TextEncoding.cpp:44
DotNetDupe::Extensions::Logging
Definition
AggregateLogger.h:8
DotNetDupe::Extensions::Logging::LogLevel
LogLevel
Defines logging severity levels.
Definition
ILogger.h:15
DotNetDupe::Extensions
Definition
IServiceCollection.h:8
DotNetDupe::System::Text::EncodingPtr
SmartPointer< Encoding > EncodingPtr
SmartPointer alias for Encoding instances.
Definition
TextEncoding.h:20
DotNetDupe
Definition
IServiceCollection.h:7
pch.h
DotNetDupe
LoggerTextWriter.cpp
Generated by
1.18.0