DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
AggregateLogger.cpp
Go to the documentation of this file.
1#include "pch.h"
4
5namespace 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
14 : m_pImpl(DotNetDupe::System::SmartPointer<Impl>::NewShared()) {
16 }
17
19
22 if (pLogger.IsNull()) return;
23
25 m_pImpl->pLoggers.Add(pLogger);
26 }
27
30 for (int iIdx = 0; iIdx < m_pImpl->pLoggers.GetCount(); ++iIdx) {
31 m_pImpl->pLoggers[iIdx]->Log(logLevel, message);
32 }
33 }
34
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}
Represents a strongly typed list of objects that can be accessed by index mirroring ....
AggregateLogger()
Initializes an empty AggregateLogger composite.
void AddLogger(const DotNetDupe::System::SmartPointer< ILogger > &pLogger)
Adds a child ILogger destination to the dispatch list.
void Log(LogLevel logLevel, const DotNetDupe::System::String &message) override
Dispatches a plain text message to all attached child loggers.
~AggregateLogger() override
Destructor releasing aggregated loggers.
bool IsEnabled(LogLevel logLevel) const override
Checks if any attached child logger is enabled for the specified level.
Represents a collection of keys and values.
Definition Dictionary.h:66
A unified smart pointer that supports both unique and shared ownership semantics.
bool IsNull() const noexcept
Checks if the SmartPointer is null.
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
LogLevel
Defines logging severity levels.
Definition ILogger.h:15