DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
ConsoleLogger.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
Extensions/Logging/ConsoleLogger.h
"
3
#include "
System/Console.h
"
4
#include <iostream>
5
6
namespace
DotNetDupe
{
7
namespace
Extensions
{
8
namespace
Logging
{
9
10
ConsoleLogger::ConsoleLogger
(
const
DotNetDupe::System::String
& categoryName,
const
LoggerConfiguration
& config)
11
:
LoggerBase
(categoryName, config) {
13
}
14
15
void
ConsoleLogger::Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message) {
17
LoggerBase::Log
(logLevel, message);
18
}
19
20
void
ConsoleLogger::Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message,
21
const
DotNetDupe::System::Collections::Generic::Dictionary<DotNetDupe::System::String, DotNetDupe::System::String>
& properties) {
23
if
(!
IsEnabled
(logLevel))
return
;
24
26
DotNetDupe::System::String
sFormatted =
BuildLogMessage
(logLevel, message, properties);
27
29
if
(!
DotNetDupe::System::Console::Out
().IsNull()) {
30
std::cout << sFormatted.
GetRawString
() << std::endl;
31
}
else
{
32
DotNetDupe::System::Console::WriteLine
(sFormatted);
33
}
34
}
35
36
}
37
}
38
}
Console.h
Represents standard input, output, and error streams for console applications.
ConsoleLogger.h
DotNetDupe::Extensions::Logging::ConsoleLogger::ConsoleLogger
ConsoleLogger(const DotNetDupe::System::String &categoryName, const LoggerConfiguration &config)
Initializes a new instance of ConsoleLogger with category name and configuration.
Definition
ConsoleLogger.cpp:10
DotNetDupe::Extensions::Logging::ConsoleLogger::Log
void Log(LogLevel logLevel, const DotNetDupe::System::String &message) override
Writes a log entry to the console.
Definition
ConsoleLogger.cpp:15
DotNetDupe::Extensions::Logging::LoggerBase::Log
void Log(LogLevel logLevel, const DotNetDupe::System::String &message) override
Writes a log entry without extra structured properties.
Definition
LoggerBase.cpp:24
DotNetDupe::Extensions::Logging::LoggerBase::IsEnabled
bool IsEnabled(LogLevel logLevel) const override
Checks whether logging is enabled for the specified log level.
Definition
LoggerBase.cpp:19
DotNetDupe::Extensions::Logging::LoggerBase::BuildLogMessage
DotNetDupe::System::String BuildLogMessage(LogLevel logLevel, const DotNetDupe::System::String &message, const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties) const
Builds the final log message string applying plain text or JSON serialization.
Definition
LoggerBase.cpp:155
DotNetDupe::Extensions::Logging::LoggerBase::LoggerBase
LoggerBase(const DotNetDupe::System::String &categoryName, const LoggerConfiguration &config)
Initializes a new LoggerBase instance with category name and configuration.
Definition
LoggerBase.cpp:14
DotNetDupe::System::Collections::Generic::Dictionary
Represents a collection of keys and values.
Definition
Dictionary.h:66
DotNetDupe::System::Console::WriteLine
static void WriteLine()
Definition
Console.cpp:97
DotNetDupe::System::Console::Out
static SmartPointer< IO::TextWriter > Out()
Definition
Console.cpp:394
DotNetDupe::System::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
DotNetDupe::System::String::GetRawString
const char * GetRawString() const
Definition
String.cpp:230
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
Definition
IServiceCollection.h:7
pch.h
DotNetDupe::Extensions::Logging::LoggerConfiguration
Encapsulates logging system configuration options.
Definition
LoggerConfiguration.h:26
DotNetDupe
ConsoleLogger.cpp
Generated by
1.18.0