DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::Extensions::Logging Namespace Reference

Classes

class  AggregateLogger
 Composite ILogger implementation that fans out log messages to multiple underlying loggers. More...
class  ConsoleLogger
 Implementation of ILogger that outputs formatted logs to standard output. More...
class  ConsoleLoggerProvider
 Provider that creates ConsoleLogger instances configured with shared settings. More...
class  FileLogger
 Implementation of ILogger that appends formatted logs to a file on disk. More...
struct  FileLoggerContext
class  FileLoggerProvider
 Provider that creates FileLogger instances sharing a file handle and rotation context. More...
struct  FileRolloverConfig
 Configuration settings for file rotation and archival. [Microsoft.Extensions.Logging]. More...
class  ILogger
 Represents a type used to perform logging. More...
class  ILoggerFactory
 Represents a type used to configure the logging system and create instances of ILogger. More...
class  ILoggerOf
 A generic interface for logging where the category name is derived from the specified type name. More...
class  ILoggerProvider
 Represents a type that can create instances of ILogger. More...
class  Logger
 Delegates logging to a wrapped ILogger instance where category is based on T. More...
class  LoggerBase
 Abstract base class providing common formatting and level filtering for loggers. More...
struct  LoggerConfiguration
 Encapsulates logging system configuration options. More...
class  LoggerFactory
 Factory class used to configure logging providers and create ILogger instances. More...
class  LoggerTextWriter
 Adapter that routes System::IO::TextWriter stream writes into an ILogger destination. More...
class  LogManager
 Central thread-safe static registry and entry point for application logging. More...

Enumerations

enum class  LogLevel {
  Trace = 0 , Debug = 1 , Information = 2 , Warning = 3 ,
  Error = 4 , Critical = 5 , None = 6
}
 Defines logging severity levels. More...

Functions

static void AddJsonLogProperties (DotNetDupe::System::Text::Json::JsonElement &logObj, const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties)
static DotNetDupe::System::String BuildJsonLog (const DotNetDupe::System::String &timestamp, const char *level, const DotNetDupe::System::String &category, int procId, unsigned long threadId, const DotNetDupe::System::String &message, const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties)
static void CheckAndRollover (const LoggerConfiguration &config, FileLoggerContext *pContext, int iLineLength)
LogLevel ParseLogLevel (const DotNetDupe::System::String &str)
 Parses a case-insensitive string into a corresponding LogLevel enumeration value.
static void PerformFileRollover (const LoggerConfiguration &config, FileLoggerContext *pContext)
static void ReplaceDynamicPropertyTokens (std::string &str, const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties, std::vector< std::string > &usedKeys)
static void ReplaceToken (std::string &str, const std::string &from, const char *to)
static DotNetDupe::System::String ResolveAndPrepareLogPath (const DotNetDupe::System::String &rawFilePath)
static std::string SerializeUnusedPropertiesText (const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > &properties, const std::vector< std::string > &usedKeys)

Enumeration Type Documentation

◆ LogLevel

Defines logging severity levels.

Modeled after Microsoft.Extensions.Logging.LogLevel. [Microsoft.Extensions.Logging]

Enumerator
Trace 

Logs that contain the most detailed messages.

Debug 

Logs that are used for interactive investigation during development.

Information 

Logs that track the general flow of the application.

Warning 

Logs that highlight an abnormal or unexpected event.

Error 

Logs that highlight when the current flow of execution is stopped due to a failure.

Critical 

Logs that describe an unrecoverable application or system crash.

None 

Not used for writing log messages. Specifies that a logging category should not write any messages.

Definition at line 15 of file ILogger.h.

Function Documentation

◆ AddJsonLogProperties()

◆ BuildJsonLog()

DotNetDupe::System::String DotNetDupe::Extensions::Logging::BuildJsonLog ( const DotNetDupe::System::String & timestamp,
const char * level,
const DotNetDupe::System::String & category,
int procId,
unsigned long threadId,
const DotNetDupe::System::String & message,
const DotNetDupe::System::Collections::Generic::Dictionary< DotNetDupe::System::String, DotNetDupe::System::String > & properties )
static

Construct root JSON event object with standard diagnostic fields.

Append structured property attributes and return serialized JSON.

Definition at line 139 of file LoggerBase.cpp.

References AddJsonLogProperties(), BuildJsonLog(), DotNetDupe::System::Text::Json::Object, DotNetDupe::System::Text::Json::JsonElement::SetProperty(), and DotNetDupe::System::Text::Json::JsonElement::ToString().

Referenced by BuildJsonLog(), and DotNetDupe::Extensions::Logging::LoggerBase::BuildLogMessage().

◆ CheckAndRollover()

void DotNetDupe::Extensions::Logging::CheckAndRollover ( const LoggerConfiguration & config,
FileLoggerContext * pContext,
int iLineLength )
static

◆ ParseLogLevel()

LogLevel DotNetDupe::Extensions::Logging::ParseLogLevel ( const DotNetDupe::System::String & str)

Parses a case-insensitive string into a corresponding LogLevel enumeration value.

Parameters
strString name of the log level (e.g., "Information", "Debug", "Error").
Returns
The parsed LogLevel enum value, or LogLevel::Information on unrecognized input.

Normalize input string to lowercase for case-insensitive comparison.

Lookup level against known string names and numeric codes (CCN <= 4).

Throw custom library exception if input is invalid.

Definition at line 160 of file LoggerConfiguration.cpp.

References Critical, Debug, Error, Information, None, ParseLogLevel(), DotNetDupe::System::String::ToLower(), Trace, and Warning.

Referenced by ParseLogLevel().

◆ PerformFileRollover()

void DotNetDupe::Extensions::Logging::PerformFileRollover ( const LoggerConfiguration & config,
FileLoggerContext * pContext )
static

Close current file handle before rotating files on disk.

Shift existing backup archives (.N to .N+1).

Rename active log file to first backup (.1).

Re-open active log file in append mode.

Definition at line 28 of file FileLogger.cpp.

References DotNetDupe::Extensions::Logging::LoggerConfiguration::FilePath, DotNetDupe::Extensions::Logging::FileLoggerContext::fileStream, DotNetDupe::System::String::GetRawString(), DotNetDupe::Extensions::Logging::FileRolloverConfig::MaxBackupFiles, PerformFileRollover(), and DotNetDupe::Extensions::Logging::LoggerConfiguration::Rollover.

Referenced by CheckAndRollover(), and PerformFileRollover().

◆ ReplaceDynamicPropertyTokens()

◆ ReplaceToken()

void DotNetDupe::Extensions::Logging::ReplaceToken ( std::string & str,
const std::string & from,
const char * to )
static

Replace all occurrences of placeholder token with replacement text.

Definition at line 66 of file LoggerBase.cpp.

References ReplaceToken().

Referenced by DotNetDupe::Extensions::Logging::LoggerBase::FormatLogLine(), ReplaceDynamicPropertyTokens(), and ReplaceToken().

◆ ResolveAndPrepareLogPath()

DotNetDupe::System::String DotNetDupe::Extensions::Logging::ResolveAndPrepareLogPath ( const DotNetDupe::System::String & rawFilePath)
static

◆ SerializeUnusedPropertiesText()