DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
AggregateLogger.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
Extensions/Logging/AggregateLogger.h
"
3
#include "
System/Collections/Generic/List.h
"
4
5
namespace
DotNetDupe
{
6
namespace
Extensions
{
7
namespace
Logging
{
8
9
struct
AggregateLogger::Impl {
10
DotNetDupe::System::Collections::Generic::List<DotNetDupe::System::SmartPointer<ILogger>> pLoggers;
11
};
12
13
AggregateLogger::AggregateLogger
()
14
: m_pImpl(
DotNetDupe
::
System
::SmartPointer<Impl>::NewShared()) {
16
}
17
18
AggregateLogger::~AggregateLogger
() =
default
;
19
20
void
AggregateLogger::AddLogger
(
const
DotNetDupe::System::SmartPointer<ILogger>
& pLogger) {
22
if
(pLogger.
IsNull
())
return
;
23
25
m_pImpl->pLoggers.Add(pLogger);
26
}
27
28
void
AggregateLogger::Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message) {
30
for
(
int
iIdx = 0; iIdx < m_pImpl->pLoggers.GetCount(); ++iIdx) {
31
m_pImpl->pLoggers[iIdx]->Log(logLevel, message);
32
}
33
}
34
35
void
AggregateLogger::Log
(
LogLevel
logLevel,
const
DotNetDupe::System::String
& message,
36
const
DotNetDupe::System::Collections::Generic::Dictionary<DotNetDupe::System::String, DotNetDupe::System::String>
& properties) {
38
for
(
int
iIdx = 0; iIdx < m_pImpl->pLoggers.GetCount(); ++iIdx) {
39
m_pImpl->pLoggers[iIdx]->Log(logLevel, message, properties);
40
}
41
}
42
43
bool
AggregateLogger::IsEnabled
(
LogLevel
logLevel)
const
{
45
for
(
int
iIdx = 0; iIdx < m_pImpl->pLoggers.GetCount(); ++iIdx) {
46
if
(m_pImpl->pLoggers[iIdx]->IsEnabled(logLevel))
return
true
;
47
}
48
50
return
false
;
51
}
52
53
}
54
}
55
}
AggregateLogger.h
List.h
Represents a strongly typed list of objects that can be accessed by index mirroring ....
DotNetDupe::Extensions::Logging::AggregateLogger::AggregateLogger
AggregateLogger()
Initializes an empty AggregateLogger composite.
Definition
AggregateLogger.cpp:13
DotNetDupe::Extensions::Logging::AggregateLogger::AddLogger
void AddLogger(const DotNetDupe::System::SmartPointer< ILogger > &pLogger)
Adds a child ILogger destination to the dispatch list.
Definition
AggregateLogger.cpp:20
DotNetDupe::Extensions::Logging::AggregateLogger::Log
void Log(LogLevel logLevel, const DotNetDupe::System::String &message) override
Dispatches a plain text message to all attached child loggers.
Definition
AggregateLogger.cpp:28
DotNetDupe::Extensions::Logging::AggregateLogger::~AggregateLogger
~AggregateLogger() override
Destructor releasing aggregated loggers.
DotNetDupe::Extensions::Logging::AggregateLogger::IsEnabled
bool IsEnabled(LogLevel logLevel) const override
Checks if any attached child logger is enabled for the specified level.
Definition
AggregateLogger.cpp:43
DotNetDupe::System::Collections::Generic::Dictionary
Represents a collection of keys and values.
Definition
Dictionary.h:66
DotNetDupe::System::SmartPointer
A unified smart pointer that supports both unique and shared ownership semantics.
Definition
SmartPointer.h:72
DotNetDupe::System::SmartPointer::IsNull
bool IsNull() const noexcept
Checks if the SmartPointer is null.
Definition
SmartPointer.h:393
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::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
pch.h
DotNetDupe
AggregateLogger.cpp
Generated by
1.18.0