DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
LoggerBase.h
Go to the documentation of this file.
1
#pragma once
2
#include "
Common.h
"
3
#include "
Extensions/Logging/ILogger.h
"
4
#include "
Extensions/Logging/LoggerConfiguration.h
"
5
6
7
namespace
DotNetDupe
{
8
namespace
Extensions
{
9
namespace
Logging
{
10
16
class
LoggerBase
:
public
ILogger
{
17
protected
:
18
DotNetDupe::System::String
m_categoryName
;
19
LoggerConfiguration
m_config
;
20
22
DotNetDupe::System::String
FormatLogLine
(
const
DotNetDupe::System::String
& fmt,
const
DotNetDupe::System::String
& timestamp,
const
DotNetDupe::System::String
& level,
const
DotNetDupe::System::String
& category,
const
DotNetDupe::System::String
& message,
const
DotNetDupe::System::String
& properties,
const
DotNetDupe::System::String
& processId,
const
DotNetDupe::System::String
& threadId)
const
;
23
25
DotNetDupe::System::String
GetFormattedTimestamp
(
const
DotNetDupe::System::String
& formatFmt)
const
;
26
28
const
char
*
LogLevelToString
(
LogLevel
level)
const
;
29
31
DotNetDupe::System::String
BuildLogMessage
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message,
32
const
DotNetDupe::System::Collections::Generic::Dictionary<DotNetDupe::System::String, DotNetDupe::System::String>
& properties)
const
;
33
34
public
:
38
DOTNETDUPE_API
LoggerBase
(
const
DotNetDupe::System::String
& categoryName,
const
LoggerConfiguration
& config);
39
41
DOTNETDUPE_API
~LoggerBase
()
override
=
default
;
42
46
DOTNETDUPE_API
bool
IsEnabled
(
LogLevel
logLevel)
const override
;
47
51
DOTNETDUPE_API
void
Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message)
override
;
52
57
DOTNETDUPE_API
void
Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message,
58
const
DotNetDupe::System::Collections::Generic::Dictionary<DotNetDupe::System::String, DotNetDupe::System::String>
& properties)
override
= 0;
59
};
60
61
}
62
}
63
}
Common.h
Defines common cross-platform macros, export decorators, and fundamental types.
DOTNETDUPE_API
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition
Common.h:20
ILogger.h
LoggerConfiguration.h
DotNetDupe::Extensions::Logging::ILogger
Represents a type used to perform logging.
Definition
ILogger.h:36
DotNetDupe::Extensions::Logging::LoggerBase::m_categoryName
DotNetDupe::System::String m_categoryName
Definition
LoggerBase.h:18
DotNetDupe::Extensions::Logging::LoggerBase::FormatLogLine
DotNetDupe::System::String FormatLogLine(const DotNetDupe::System::String &fmt, const DotNetDupe::System::String ×tamp, const DotNetDupe::System::String &level, const DotNetDupe::System::String &category, const DotNetDupe::System::String &message, const DotNetDupe::System::String &properties, const DotNetDupe::System::String &processId, const DotNetDupe::System::String &threadId) const
Formats a single log line according to configuration template.
Definition
LoggerBase.cpp:111
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::LogLevelToString
const char * LogLevelToString(LogLevel level) const
Converts a LogLevel enumeration to its uppercase string name.
Definition
LoggerBase.cpp:53
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::GetFormattedTimestamp
DotNetDupe::System::String GetFormattedTimestamp(const DotNetDupe::System::String &formatFmt) const
Generates a formatted timestamp string using strftime syntax.
Definition
LoggerBase.cpp:33
DotNetDupe::Extensions::Logging::LoggerBase::Log
void Log(LogLevel logLevel, const DotNetDupe::System::String &message, const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties) override=0
Writes a log entry with extra structured properties.
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::m_config
LoggerConfiguration m_config
Definition
LoggerBase.h:19
DotNetDupe::Extensions::Logging::LoggerBase::~LoggerBase
~LoggerBase() override=default
Virtual destructor for polymorphic cleanup.
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::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
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
DotNetDupe::Extensions::Logging::LoggerConfiguration
Encapsulates logging system configuration options.
Definition
LoggerConfiguration.h:26
Include
Extensions
Logging
LoggerBase.h
Generated by
1.18.0