diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b9627f2..7face3a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,6 +13,8 @@ jobs: build: uses: LayeredCraft/devops-templates/.github/workflows/package-build.yaml@v6.2 with: + hasTests: true + useMtpRunner: true dotnet-version: | 8.0.x 9.0.x diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index 45022e0..3121d86 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -10,6 +10,7 @@ jobs: uses: LayeredCraft/devops-templates/.github/workflows/pr-build.yaml@v6.2 with: solution: LayeredCraft.StructuredLogging.sln + useMtpRunner: true hasTests: true dotnetVersion: | 8.0.x diff --git a/Directory.Build.props b/Directory.Build.props index 77f1df3..982ebeb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.1.4 + 1.1.5 MIT diff --git a/src/LayeredCraft.StructuredLogging/CriticalExtensions.cs b/src/LayeredCraft.StructuredLogging/CriticalExtensions.cs index 4061df7..471e146 100644 --- a/src/LayeredCraft.StructuredLogging/CriticalExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/CriticalExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class CriticalExtensions { - /// - /// Logs a critical-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Critical("Application is shutting down due to critical system failure"); - /// - /// - public static void Critical(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Critical, null, message); - } + /// + /// Logs a critical-level message. + /// + /// The log message. + /// + /// + /// logger.Critical("Application is shutting down due to critical system failure"); + /// + /// + public void Critical(string? message) + { + logger.LogMessage(LogLevel.Critical, null, message); + } - /// - /// Logs a critical-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Critical("Critical system failure in module {ModuleName}", moduleName); - /// - /// - public static void Critical(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue); - } + /// + /// Logs a critical-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Critical("Critical system failure in module {ModuleName}", moduleName); + /// + /// + public void Critical(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue); + } - /// - /// Logs a critical-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Critical("Critical database failure on server {ServerName} affecting {UserCount} users", serverName, userCount); - /// - /// - public static void Critical(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs a critical-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Critical("Critical database failure on server {ServerName} affecting {UserCount} users", serverName, userCount); + /// + /// + public void Critical(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs a critical-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Critical("Critical system failure: {ServiceName} crashed on {ServerName} affecting {ImpactLevel} operations", serviceName, serverName, impactLevel); - /// - /// - public static void Critical(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a critical-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Critical("Critical system failure: {ServiceName} crashed on {ServerName} affecting {ImpactLevel} operations", serviceName, serverName, impactLevel); + /// + /// + public void Critical(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a critical-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Critical("Critical infrastructure failure: {ComponentName} on {ServerName} in {DataCenter} causing {OutageType} outage", componentName, serverName, dataCenter, outageType); - /// - /// - public static void Critical(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a critical-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Critical("Critical infrastructure failure: {ComponentName} on {ServerName} in {DataCenter} causing {OutageType} outage", componentName, serverName, dataCenter, outageType); + /// + /// + public void Critical(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a critical-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Critical("Critical security breach: {ThreatType} detected on {SystemName} in {Location} affecting {UserCount} users at {Timestamp}", threatType, systemName, location, userCount, timestamp); - /// - /// - public static void Critical(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a critical-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Critical("Critical security breach: {ThreatType} detected on {SystemName} in {Location} affecting {UserCount} users at {Timestamp}", threatType, systemName, location, userCount, timestamp); + /// + /// + public void Critical(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a critical-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Critical("Critical disaster: {DisasterType} in {Region} on {SystemName} affecting {ServiceLevel} services for {UserCount} users since {StartTime}", disasterType, region, systemName, serviceLevel, userCount, startTime); - /// - /// - public static void Critical(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs a critical-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Critical("Critical disaster: {DisasterType} in {Region} on {SystemName} affecting {ServiceLevel} services for {UserCount} users since {StartTime}", disasterType, region, systemName, serviceLevel, userCount, startTime); + /// + /// + public void Critical(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Critical, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs a critical-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Critical(exception, "Application-wide system failure requiring immediate attention"); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Critical, exception, message); - } + /// + /// Logs a critical-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Critical(exception, "Application-wide system failure requiring immediate attention"); + /// + /// + public void Critical(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Critical, exception, message); + } - /// - /// Logs a critical-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical system failure in module {ModuleName}", moduleName); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue); - } + /// + /// Logs a critical-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical system failure in module {ModuleName}", moduleName); + /// + /// + public void Critical(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue); + } - /// - /// Logs a critical-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical database failure on server {ServerName} affecting {UserCount} users", serverName, userCount); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs a critical-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical database failure on server {ServerName} affecting {UserCount} users", serverName, userCount); + /// + /// + public void Critical(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs a critical-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical system failure: {ServiceName} crashed on {ServerName} causing {ImpactLevel} impact", serviceName, serverName, impactLevel); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a critical-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical system failure: {ServiceName} crashed on {ServerName} causing {ImpactLevel} impact", serviceName, serverName, impactLevel); + /// + /// + public void Critical(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a critical-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical infrastructure failure: {ComponentName} on {ServerName} in {DataCenter} causing {OutageType} outage", componentName, serverName, dataCenter, outageType); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a critical-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical infrastructure failure: {ComponentName} on {ServerName} in {DataCenter} causing {OutageType} outage", componentName, serverName, dataCenter, outageType); + /// + /// + public void Critical(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a critical-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical security breach: {ThreatType} detected on {SystemName} in {Location} affecting {UserCount} users at {Timestamp}", threatType, systemName, location, userCount, timestamp); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a critical-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical security breach: {ThreatType} detected on {SystemName} in {Location} affecting {UserCount} users at {Timestamp}", threatType, systemName, location, userCount, timestamp); + /// + /// + public void Critical(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a critical-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Critical(exception, "Critical disaster: {DisasterType} in {Region} on {SystemName} affecting {ServiceLevel} services for {UserCount} users since {StartTime}", disasterType, region, systemName, serviceLevel, userCount, startTime); - /// - /// - public static void Critical(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs a critical-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Critical(exception, "Critical disaster: {DisasterType} in {Region} on {SystemName} affecting {ServiceLevel} services for {UserCount} users since {StartTime}", disasterType, region, systemName, serviceLevel, userCount, startTime); + /// + /// + public void Critical(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Critical, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/DebugExtensions.cs b/src/LayeredCraft.StructuredLogging/DebugExtensions.cs index 083c1bd..115282e 100644 --- a/src/LayeredCraft.StructuredLogging/DebugExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/DebugExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class DebugExtensions { - /// - /// Logs a debug-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Debug("Processing started"); - /// - /// - public static void Debug(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Debug, null, message); - } + /// + /// Logs a debug-level message. + /// + /// The log message. + /// + /// + /// logger.Debug("Processing started"); + /// + /// + public void Debug(string? message) + { + logger.LogMessage(LogLevel.Debug, null, message); + } - /// - /// Logs a debug-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Debug("Processing item {ItemId}", itemId); - /// - /// - public static void Debug(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue); - } + /// + /// Logs a debug-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Debug("Processing item {ItemId}", itemId); + /// + /// + public void Debug(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue); + } - /// - /// Logs a debug-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Debug("Processing user {UserId} in tenant {TenantId}", userId, tenantId); - /// - /// - public static void Debug(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs a debug-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Debug("Processing user {UserId} in tenant {TenantId}", userId, tenantId); + /// + /// + public void Debug(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs a debug-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Debug("Query executed in {Duration}ms for user {UserId} returning {Count} results", duration, userId, count); - /// - /// - public static void Debug(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a debug-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Debug("Query executed in {Duration}ms for user {UserId} returning {Count} results", duration, userId, count); + /// + /// + public void Debug(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a debug-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Debug("Cache operation {Operation} for key {Key} in region {Region} took {Duration}ms", operation, key, region, duration); - /// - /// - public static void Debug(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a debug-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Debug("Cache operation {Operation} for key {Key} in region {Region} took {Duration}ms", operation, key, region, duration); + /// + /// + public void Debug(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a debug-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Debug("HTTP request {Method} {Url} by user {UserId} from {IPAddress} took {Duration}ms", method, url, userId, ipAddress, duration); - /// - /// - public static void Debug(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a debug-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Debug("HTTP request {Method} {Url} by user {UserId} from {IPAddress} took {Duration}ms", method, url, userId, ipAddress, duration); + /// + /// + public void Debug(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a debug-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Debug("Database query {Query} on {Database}.{Table} by user {UserId} from {Host} took {Duration}ms with {RowCount} rows", query, database, table, userId, host, duration, rowCount); - /// - /// - public static void Debug(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs a debug-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Debug("Database query {Query} on {Database}.{Table} by user {UserId} from {Host} took {Duration}ms with {RowCount} rows", query, database, table, userId, host, duration, rowCount); + /// + /// + public void Debug(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Debug, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs a debug-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Debug(exception, "Failed to process item during debugging"); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Debug, exception, message); - } + /// + /// Logs a debug-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Debug(exception, "Failed to process item during debugging"); + /// + /// + public void Debug(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Debug, exception, message); + } - /// - /// Logs a debug-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "Failed to process item {ItemId}", itemId); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue); - } + /// + /// Logs a debug-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "Failed to process item {ItemId}", itemId); + /// + /// + public void Debug(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue); + } - /// - /// Logs a debug-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "Failed to process user {UserId} in tenant {TenantId}", userId, tenantId); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs a debug-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "Failed to process user {UserId} in tenant {TenantId}", userId, tenantId); + /// + /// + public void Debug(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs a debug-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "Query failed after {Duration}ms for user {UserId} with {Count} retries", duration, userId, retryCount); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a debug-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "Query failed after {Duration}ms for user {UserId} with {Count} retries", duration, userId, retryCount); + /// + /// + public void Debug(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a debug-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "Cache operation {Operation} failed for key {Key} in region {Region} after {Duration}ms", operation, key, region, duration); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a debug-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "Cache operation {Operation} failed for key {Key} in region {Region} after {Duration}ms", operation, key, region, duration); + /// + /// + public void Debug(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a debug-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "HTTP request {Method} {Url} by user {UserId} from {IPAddress} failed after {Duration}ms", method, url, userId, ipAddress, duration); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a debug-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "HTTP request {Method} {Url} by user {UserId} from {IPAddress} failed after {Duration}ms", method, url, userId, ipAddress, duration); + /// + /// + public void Debug(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a debug-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Debug(exception, "Database query {Query} on {Database}.{Table} by user {UserId} from {Host} failed after {Duration}ms with {RowCount} rows processed", query, database, table, userId, host, duration, rowCount); - /// - /// - public static void Debug(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs a debug-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Debug(exception, "Database query {Query} on {Database}.{Table} by user {UserId} from {Host} failed after {Duration}ms with {RowCount} rows processed", query, database, table, userId, host, duration, rowCount); + /// + /// + public void Debug(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Debug, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/EnrichmentExtensions.cs b/src/LayeredCraft.StructuredLogging/EnrichmentExtensions.cs index 82db787..bdf7991 100644 --- a/src/LayeredCraft.StructuredLogging/EnrichmentExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/EnrichmentExtensions.cs @@ -11,323 +11,310 @@ namespace LayeredCraft.StructuredLogging; /// public static class EnrichmentExtensions { - /// - /// Logs a message with additional context information by creating a temporary scope with the specified context property. - /// - /// The type of the context value. /// The logger instance. - /// The log level for the message. - /// The log message. - /// The name of the context property to add. - /// The value of the context property to add. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.LogWithContext(LogLevel.Information, "Operation completed", "Duration", duration); - /// - /// - public static void LogWithContext(this ILogger logger, LogLevel logLevel, string? message, string contextName, T contextValue, Exception? exception = null) + extension(ILogger logger) { - if (logger.IsEnabled(logLevel)) + /// + /// Logs a message with additional context information by creating a temporary scope with the specified context property. + /// + /// The type of the context value. + /// The log level for the message. + /// The log message. + /// The name of the context property to add. + /// The value of the context property to add. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.LogWithContext(LogLevel.Information, "Operation completed", "Duration", duration); + /// + /// + public void LogWithContext(LogLevel logLevel, string? message, string contextName, T contextValue, Exception? exception = null) { - using var scope = logger.BeginScope(contextName, contextValue); - logger.Log(logLevel, exception, message); + if (logger.IsEnabled(logLevel)) + { + using var scope = logger.BeginScope(contextName, contextValue); + logger.Log(logLevel, exception, message); + } } - } - /// - /// Logs a message with a UserId context property for user-specific operations. - /// - /// The logger instance. - /// The log level for the message. - /// The user identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.LogWithUserId(LogLevel.Information, "user123", "User login successful"); - /// - /// - public static void LogWithUserId(this ILogger logger, LogLevel logLevel, string userId, string? message, Exception? exception = null) - { - logger.LogWithContext(logLevel, message, "UserId", userId, exception); - } + /// + /// Logs a message with a UserId context property for user-specific operations. + /// + /// The log level for the message. + /// The user identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.LogWithUserId(LogLevel.Information, "user123", "User login successful"); + /// + /// + public void LogWithUserId(LogLevel logLevel, string userId, string? message, Exception? exception = null) + { + logger.LogWithContext(logLevel, message, "UserId", userId, exception); + } - /// - /// Logs a message with a RequestId context property for request-specific operations. - /// - /// The logger instance. - /// The log level for the message. - /// The request identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.LogWithRequestId(LogLevel.Warning, "req-456", "Request processing slow"); - /// - /// - public static void LogWithRequestId(this ILogger logger, LogLevel logLevel, string requestId, string? message, Exception? exception = null) - { - logger.LogWithContext(logLevel, message, "RequestId", requestId, exception); - } + /// + /// Logs a message with a RequestId context property for request-specific operations. + /// + /// The log level for the message. + /// The request identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.LogWithRequestId(LogLevel.Warning, "req-456", "Request processing slow"); + /// + /// + public void LogWithRequestId(LogLevel logLevel, string requestId, string? message, Exception? exception = null) + { + logger.LogWithContext(logLevel, message, "RequestId", requestId, exception); + } - /// - /// Logs a message with a CorrelationId context property for distributed tracing. - /// - /// The logger instance. - /// The log level for the message. - /// The correlation identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.LogWithCorrelationId(LogLevel.Error, "corr-789", "Service call failed", ex); - /// - /// - public static void LogWithCorrelationId(this ILogger logger, LogLevel logLevel, string correlationId, string? message, Exception? exception = null) - { - logger.LogWithContext(logLevel, message, "CorrelationId", correlationId, exception); - } + /// + /// Logs a message with a CorrelationId context property for distributed tracing. + /// + /// The log level for the message. + /// The correlation identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.LogWithCorrelationId(LogLevel.Error, "corr-789", "Service call failed", ex); + /// + /// + public void LogWithCorrelationId(LogLevel logLevel, string correlationId, string? message, Exception? exception = null) + { + logger.LogWithContext(logLevel, message, "CorrelationId", correlationId, exception); + } - /// - /// Logs a message with automatic caller information including method name, file path, and line number. - /// - /// The logger instance. - /// The log level for the message. - /// The log message. - /// The exception associated with the log entry, if any. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// - /// - /// logger.LogWithCaller(LogLevel.Debug, "Method execution completed"); - /// - /// - public static void LogWithCaller(this ILogger logger, LogLevel logLevel, string? message, Exception? exception = null, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - if (logger.IsEnabled(logLevel)) + /// + /// Logs a message with automatic caller information including method name, file path, and line number. + /// + /// The log level for the message. + /// The log message. + /// The exception associated with the log entry, if any. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// + /// + /// logger.LogWithCaller(LogLevel.Debug, "Method execution completed"); + /// + /// + public void LogWithCaller(LogLevel logLevel, string? message, Exception? exception = null, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) { - using var scope = logger.BeginCallerScope(memberName, filePath, lineNumber); - logger.Log(logLevel, exception, message); + if (logger.IsEnabled(logLevel)) + { + using var scope = logger.BeginCallerScope(memberName, filePath, lineNumber); + logger.Log(logLevel, exception, message); + } } - } - /// - /// Logs an Information level message with UserId context for user-specific operations. - /// - /// The logger instance. - /// The user identifier to include in the log context. - /// The log message. - /// - /// - /// logger.InformationWithUserId("user123", "User profile updated"); - /// - /// - public static void InformationWithUserId(this ILogger logger, string userId, string? message) - { - logger.LogWithUserId(LogLevel.Information, userId, message); - } + /// + /// Logs an Information level message with UserId context for user-specific operations. + /// + /// The user identifier to include in the log context. + /// The log message. + /// + /// + /// logger.InformationWithUserId("user123", "User profile updated"); + /// + /// + public void InformationWithUserId(string userId, string? message) + { + logger.LogWithUserId(LogLevel.Information, userId, message); + } - /// - /// Logs an Information level message with RequestId context for request-specific operations. - /// - /// The logger instance. - /// The request identifier to include in the log context. - /// The log message. - /// - /// - /// logger.InformationWithRequestId("req-456", "Request processed successfully"); - /// - /// - public static void InformationWithRequestId(this ILogger logger, string requestId, string? message) - { - logger.LogWithRequestId(LogLevel.Information, requestId, message); - } + /// + /// Logs an Information level message with RequestId context for request-specific operations. + /// + /// The request identifier to include in the log context. + /// The log message. + /// + /// + /// logger.InformationWithRequestId("req-456", "Request processed successfully"); + /// + /// + public void InformationWithRequestId(string requestId, string? message) + { + logger.LogWithRequestId(LogLevel.Information, requestId, message); + } - /// - /// Logs an Information level message with CorrelationId context for distributed tracing. - /// - /// The logger instance. - /// The correlation identifier to include in the log context. - /// The log message. - /// - /// - /// logger.InformationWithCorrelationId("corr-789", "Service operation completed"); - /// - /// - public static void InformationWithCorrelationId(this ILogger logger, string correlationId, string? message) - { - logger.LogWithCorrelationId(LogLevel.Information, correlationId, message); - } + /// + /// Logs an Information level message with CorrelationId context for distributed tracing. + /// + /// The correlation identifier to include in the log context. + /// The log message. + /// + /// + /// logger.InformationWithCorrelationId("corr-789", "Service operation completed"); + /// + /// + public void InformationWithCorrelationId(string correlationId, string? message) + { + logger.LogWithCorrelationId(LogLevel.Information, correlationId, message); + } - /// - /// Logs an Information level message with automatic caller information. - /// - /// The logger instance. - /// The log message. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// - /// - /// logger.InformationWithCaller("Method execution completed"); - /// - /// - public static void InformationWithCaller(this ILogger logger, string? message, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - logger.LogWithCaller(LogLevel.Information, message, null, memberName, filePath, lineNumber); - } + /// + /// Logs an Information level message with automatic caller information. + /// + /// The log message. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// + /// + /// logger.InformationWithCaller("Method execution completed"); + /// + /// + public void InformationWithCaller(string? message, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) + { + logger.LogWithCaller(LogLevel.Information, message, null, memberName, filePath, lineNumber); + } - /// - /// Logs a Warning level message with UserId context for user-specific warnings. - /// - /// The logger instance. - /// The user identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.WarningWithUserId("user123", "User exceeded rate limit"); - /// - /// - public static void WarningWithUserId(this ILogger logger, string userId, string? message, Exception? exception = null) - { - logger.LogWithUserId(LogLevel.Warning, userId, message, exception); - } + /// + /// Logs a Warning level message with UserId context for user-specific warnings. + /// + /// The user identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.WarningWithUserId("user123", "User exceeded rate limit"); + /// + /// + public void WarningWithUserId(string userId, string? message, Exception? exception = null) + { + logger.LogWithUserId(LogLevel.Warning, userId, message, exception); + } - /// - /// Logs a Warning level message with RequestId context for request-specific warnings. - /// - /// The logger instance. - /// The request identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.WarningWithRequestId("req-456", "Request took longer than expected"); - /// - /// - public static void WarningWithRequestId(this ILogger logger, string requestId, string? message, Exception? exception = null) - { - logger.LogWithRequestId(LogLevel.Warning, requestId, message, exception); - } + /// + /// Logs a Warning level message with RequestId context for request-specific warnings. + /// + /// The request identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.WarningWithRequestId("req-456", "Request took longer than expected"); + /// + /// + public void WarningWithRequestId(string requestId, string? message, Exception? exception = null) + { + logger.LogWithRequestId(LogLevel.Warning, requestId, message, exception); + } - /// - /// Logs a Warning level message with CorrelationId context for distributed tracing warnings. - /// - /// The logger instance. - /// The correlation identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.WarningWithCorrelationId("corr-789", "Service degraded performance"); - /// - /// - public static void WarningWithCorrelationId(this ILogger logger, string correlationId, string? message, Exception? exception = null) - { - logger.LogWithCorrelationId(LogLevel.Warning, correlationId, message, exception); - } + /// + /// Logs a Warning level message with CorrelationId context for distributed tracing warnings. + /// + /// The correlation identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.WarningWithCorrelationId("corr-789", "Service degraded performance"); + /// + /// + public void WarningWithCorrelationId(string correlationId, string? message, Exception? exception = null) + { + logger.LogWithCorrelationId(LogLevel.Warning, correlationId, message, exception); + } - /// - /// Logs a Warning level message with automatic caller information. - /// - /// The logger instance. - /// The log message. - /// The exception associated with the log entry, if any. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// - /// - /// logger.WarningWithCaller("Method execution took longer than expected"); - /// - /// - public static void WarningWithCaller(this ILogger logger, string? message, Exception? exception = null, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - logger.LogWithCaller(LogLevel.Warning, message, exception, memberName, filePath, lineNumber); - } + /// + /// Logs a Warning level message with automatic caller information. + /// + /// The log message. + /// The exception associated with the log entry, if any. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// + /// + /// logger.WarningWithCaller("Method execution took longer than expected"); + /// + /// + public void WarningWithCaller(string? message, Exception? exception = null, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) + { + logger.LogWithCaller(LogLevel.Warning, message, exception, memberName, filePath, lineNumber); + } - /// - /// Logs an Error level message with UserId context for user-specific errors. - /// - /// The logger instance. - /// The user identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.ErrorWithUserId("user123", "User authentication failed", authException); - /// - /// - public static void ErrorWithUserId(this ILogger logger, string userId, string? message, Exception? exception = null) - { - logger.LogWithUserId(LogLevel.Error, userId, message, exception); - } + /// + /// Logs an Error level message with UserId context for user-specific errors. + /// + /// The user identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.ErrorWithUserId("user123", "User authentication failed", authException); + /// + /// + public void ErrorWithUserId(string userId, string? message, Exception? exception = null) + { + logger.LogWithUserId(LogLevel.Error, userId, message, exception); + } - /// - /// Logs an Error level message with RequestId context for request-specific errors. - /// - /// The logger instance. - /// The request identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.ErrorWithRequestId("req-456", "Request processing failed", processingException); - /// - /// - public static void ErrorWithRequestId(this ILogger logger, string requestId, string? message, Exception? exception = null) - { - logger.LogWithRequestId(LogLevel.Error, requestId, message, exception); - } + /// + /// Logs an Error level message with RequestId context for request-specific errors. + /// + /// The request identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.ErrorWithRequestId("req-456", "Request processing failed", processingException); + /// + /// + public void ErrorWithRequestId(string requestId, string? message, Exception? exception = null) + { + logger.LogWithRequestId(LogLevel.Error, requestId, message, exception); + } - /// - /// Logs an Error level message with CorrelationId context for distributed tracing errors. - /// - /// The logger instance. - /// The correlation identifier to include in the log context. - /// The log message. - /// The exception associated with the log entry, if any. - /// - /// - /// logger.ErrorWithCorrelationId("corr-789", "Service call failed", serviceException); - /// - /// - public static void ErrorWithCorrelationId(this ILogger logger, string correlationId, string? message, Exception? exception = null) - { - logger.LogWithCorrelationId(LogLevel.Error, correlationId, message, exception); - } + /// + /// Logs an Error level message with CorrelationId context for distributed tracing errors. + /// + /// The correlation identifier to include in the log context. + /// The log message. + /// The exception associated with the log entry, if any. + /// + /// + /// logger.ErrorWithCorrelationId("corr-789", "Service call failed", serviceException); + /// + /// + public void ErrorWithCorrelationId(string correlationId, string? message, Exception? exception = null) + { + logger.LogWithCorrelationId(LogLevel.Error, correlationId, message, exception); + } - /// - /// Logs an Error level message with automatic caller information. - /// - /// The logger instance. - /// The log message. - /// The exception associated with the log entry, if any. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// - /// - /// logger.ErrorWithCaller("Method execution failed", methodException); - /// - /// - public static void ErrorWithCaller(this ILogger logger, string? message, Exception? exception = null, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - logger.LogWithCaller(LogLevel.Error, message, exception, memberName, filePath, lineNumber); + /// + /// Logs an Error level message with automatic caller information. + /// + /// The log message. + /// The exception associated with the log entry, if any. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// + /// + /// logger.ErrorWithCaller("Method execution failed", methodException); + /// + /// + public void ErrorWithCaller(string? message, Exception? exception = null, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) + { + logger.LogWithCaller(LogLevel.Error, message, exception, memberName, filePath, lineNumber); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/ErrorExtensions.cs b/src/LayeredCraft.StructuredLogging/ErrorExtensions.cs index 50aa382..1c09cd1 100644 --- a/src/LayeredCraft.StructuredLogging/ErrorExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/ErrorExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class ErrorExtensions { - /// - /// Logs an error-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Error("Failed to process payment transaction"); - /// - /// - public static void Error(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Error, null, message); - } + /// + /// Logs an error-level message. + /// + /// The log message. + /// + /// + /// logger.Error("Failed to process payment transaction"); + /// + /// + public void Error(string? message) + { + logger.LogMessage(LogLevel.Error, null, message); + } - /// - /// Logs an error-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Error("Failed to process order {OrderId}", orderId); - /// - /// - public static void Error(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue); - } + /// + /// Logs an error-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Error("Failed to process order {OrderId}", orderId); + /// + /// + public void Error(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue); + } - /// - /// Logs an error-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Error("Database connection failed for user {UserId} with error code {ErrorCode}", userId, errorCode); - /// - /// - public static void Error(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs an error-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Error("Database connection failed for user {UserId} with error code {ErrorCode}", userId, errorCode); + /// + /// + public void Error(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs an error-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Error("Payment processing failed for amount {Amount} {Currency} on order {OrderId}", amount, currency, orderId); - /// - /// - public static void Error(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs an error-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Error("Payment processing failed for amount {Amount} {Currency} on order {OrderId}", amount, currency, orderId); + /// + /// + public void Error(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs an error-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Error("Service {ServiceName} failed on {ServerName} with error {ErrorCode} after {Duration}ms", serviceName, serverName, errorCode, duration); - /// - /// - public static void Error(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs an error-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Error("Service {ServiceName} failed on {ServerName} with error {ErrorCode} after {Duration}ms", serviceName, serverName, errorCode, duration); + /// + /// + public void Error(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs an error-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Error("API call to {Endpoint} failed with {StatusCode} for user {UserId} from {IPAddress} after {RetryCount} retries", endpoint, statusCode, userId, ipAddress, retryCount); - /// - /// - public static void Error(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs an error-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Error("API call to {Endpoint} failed with {StatusCode} for user {UserId} from {IPAddress} after {RetryCount} retries", endpoint, statusCode, userId, ipAddress, retryCount); + /// + /// + public void Error(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs an error-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Error("Database operation {Operation} failed on {Database}.{Table} for user {UserId} from {Host} with timeout {Timeout}ms", operation, database, table, userId, host, timeout); - /// - /// - public static void Error(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs an error-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Error("Database operation {Operation} failed on {Database}.{Table} for user {UserId} from {Host} with timeout {Timeout}ms", operation, database, table, userId, host, timeout); + /// + /// + public void Error(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Error, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs an error-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Error(exception, "Payment processing system failure"); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Error, exception, message); - } + /// + /// Logs an error-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Error(exception, "Payment processing system failure"); + /// + /// + public void Error(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Error, exception, message); + } - /// - /// Logs an error-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Error(exception, "Failed to process order {OrderId}", orderId); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue); - } + /// + /// Logs an error-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Error(exception, "Failed to process order {OrderId}", orderId); + /// + /// + public void Error(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue); + } - /// - /// Logs an error-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Error(exception, "Database connection failed for user {UserId} with error code {ErrorCode}", userId, errorCode); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs an error-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Error(exception, "Database connection failed for user {UserId} with error code {ErrorCode}", userId, errorCode); + /// + /// + public void Error(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs an error-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Error(exception, "Payment processing failed for amount {Amount} {Currency} on order {OrderId}", amount, currency, orderId); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs an error-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Error(exception, "Payment processing failed for amount {Amount} {Currency} on order {OrderId}", amount, currency, orderId); + /// + /// + public void Error(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs an error-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Error(exception, "Service {ServiceName} failed on {ServerName} with error {ErrorCode} after {Duration}ms", serviceName, serverName, errorCode, duration); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs an error-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Error(exception, "Service {ServiceName} failed on {ServerName} with error {ErrorCode} after {Duration}ms", serviceName, serverName, errorCode, duration); + /// + /// + public void Error(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs an error-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Error(exception, "API call to {Endpoint} failed with {StatusCode} for user {UserId} from {IPAddress} after {RetryCount} retries", endpoint, statusCode, userId, ipAddress, retryCount); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs an error-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Error(exception, "API call to {Endpoint} failed with {StatusCode} for user {UserId} from {IPAddress} after {RetryCount} retries", endpoint, statusCode, userId, ipAddress, retryCount); + /// + /// + public void Error(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs an error-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Error(exception, "Database operation {Operation} failed on {Database}.{Table} for user {UserId} from {Host} with timeout {Timeout}ms", operation, database, table, userId, host, timeout); - /// - /// - public static void Error(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs an error-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Error(exception, "Database operation {Operation} failed on {Database}.{Table} for user {UserId} from {Host} with timeout {Timeout}ms", operation, database, table, userId, host, timeout); + /// + /// + public void Error(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Error, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/InformationExtensions.cs b/src/LayeredCraft.StructuredLogging/InformationExtensions.cs index 05e9b96..454fc73 100644 --- a/src/LayeredCraft.StructuredLogging/InformationExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/InformationExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class InformationExtensions { - /// - /// Logs an information-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Information("User logged in successfully"); - /// - /// - public static void Information(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Information, null, message); - } + /// + /// Logs an information-level message. + /// + /// The log message. + /// + /// + /// logger.Information("User logged in successfully"); + /// + /// + public void Information(string? message) + { + logger.LogMessage(LogLevel.Information, null, message); + } - /// - /// Logs an information-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Information("User {UserId} logged in successfully", userId); - /// - /// - public static void Information(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue); - } + /// + /// Logs an information-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Information("User {UserId} logged in successfully", userId); + /// + /// + public void Information(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue); + } - /// - /// Logs an information-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Information("Order {OrderId} processed for customer {CustomerId}", orderId, customerId); - /// - /// - public static void Information(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs an information-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Information("Order {OrderId} processed for customer {CustomerId}", orderId, customerId); + /// + /// + public void Information(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs an information-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Information("API request {Method} {Endpoint} completed with status {StatusCode}", method, endpoint, statusCode); - /// - /// - public static void Information(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs an information-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Information("API request {Method} {Endpoint} completed with status {StatusCode}", method, endpoint, statusCode); + /// + /// + public void Information(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs an information-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Information("Payment {PaymentId} of {Amount} {Currency} processed for order {OrderId}", paymentId, amount, currency, orderId); - /// - /// - public static void Information(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs an information-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Information("Payment {PaymentId} of {Amount} {Currency} processed for order {OrderId}", paymentId, amount, currency, orderId); + /// + /// + public void Information(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs an information-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Information("File {FileName} uploaded by user {UserId} to {BucketName} with size {FileSize} and type {ContentType}", fileName, userId, bucketName, fileSize, contentType); - /// - /// - public static void Information(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs an information-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Information("File {FileName} uploaded by user {UserId} to {BucketName} with size {FileSize} and type {ContentType}", fileName, userId, bucketName, fileSize, contentType); + /// + /// + public void Information(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs an information-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Information("Transaction {TransactionId} processed: {Amount} {Currency} from {SourceAccount} to {TargetAccount} at {Timestamp}", transactionId, amount, currency, sourceAccount, targetAccount, timestamp); - /// - /// - public static void Information(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs an information-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Information("Transaction {TransactionId} processed: {Amount} {Currency} from {SourceAccount} to {TargetAccount} at {Timestamp}", transactionId, amount, currency, sourceAccount, targetAccount, timestamp); + /// + /// + public void Information(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Information, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs an information-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Information(exception, "Operation completed with warnings"); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Information, exception, message); - } + /// + /// Logs an information-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Information(exception, "Operation completed with warnings"); + /// + /// + public void Information(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Information, exception, message); + } - /// - /// Logs an information-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Information(exception, "User {UserId} operation completed with warnings", userId); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue); - } + /// + /// Logs an information-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Information(exception, "User {UserId} operation completed with warnings", userId); + /// + /// + public void Information(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue); + } - /// - /// Logs an information-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Information(exception, "Order {OrderId} processed for customer {CustomerId} with warnings", orderId, customerId); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs an information-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Information(exception, "Order {OrderId} processed for customer {CustomerId} with warnings", orderId, customerId); + /// + /// + public void Information(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs an information-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Information(exception, "API request {Method} {Endpoint} completed with status {StatusCode} and warnings", method, endpoint, statusCode); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs an information-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Information(exception, "API request {Method} {Endpoint} completed with status {StatusCode} and warnings", method, endpoint, statusCode); + /// + /// + public void Information(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs an information-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Information(exception, "Payment {PaymentId} of {Amount} {Currency} processed for order {OrderId} with warnings", paymentId, amount, currency, orderId); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs an information-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Information(exception, "Payment {PaymentId} of {Amount} {Currency} processed for order {OrderId} with warnings", paymentId, amount, currency, orderId); + /// + /// + public void Information(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs an information-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Information(exception, "File {FileName} uploaded by user {UserId} to {BucketName} with size {FileSize} and type {ContentType} but with warnings", fileName, userId, bucketName, fileSize, contentType); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs an information-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Information(exception, "File {FileName} uploaded by user {UserId} to {BucketName} with size {FileSize} and type {ContentType} but with warnings", fileName, userId, bucketName, fileSize, contentType); + /// + /// + public void Information(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs an information-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Information(exception, "Transaction {TransactionId} processed: {Amount} {Currency} from {SourceAccount} to {TargetAccount} at {Timestamp} with warnings", transactionId, amount, currency, sourceAccount, targetAccount, timestamp); - /// - /// - public static void Information(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs an information-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Information(exception, "Transaction {TransactionId} processed: {Amount} {Currency} from {SourceAccount} to {TargetAccount} at {Timestamp} with warnings", transactionId, amount, currency, sourceAccount, targetAccount, timestamp); + /// + /// + public void Information(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Information, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/LoggerExtensionsBase.cs b/src/LayeredCraft.StructuredLogging/LoggerExtensionsBase.cs index ea26428..f45be35 100644 --- a/src/LayeredCraft.StructuredLogging/LoggerExtensionsBase.cs +++ b/src/LayeredCraft.StructuredLogging/LoggerExtensionsBase.cs @@ -7,142 +7,139 @@ namespace LayeredCraft.StructuredLogging; /// internal static class LoggerExtensionsBase { - /// - /// Logs a message at the specified log level with optional exception, checking if logging is enabled first. - /// /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, string? message) + extension(ILogger logger) { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message); - } + /// + /// Logs a message at the specified log level with optional exception, checking if logging is enabled first. + /// + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + internal void LogMessage(LogLevel logLevel, Exception? exception, string? message) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message); + } - /// - /// Logs a message at the specified log level with one typed property value, checking if logging is enabled first. - /// - /// The type of the property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, string? message, - T? propertyValue) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue }); - } + /// + /// Logs a message at the specified log level with one typed property value, checking if logging is enabled first. + /// + /// The type of the property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, string? message, + T? propertyValue) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue }); + } - /// - /// Logs a message at the specified log level with two typed property values, checking if logging is enabled first. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, - string? message, T0? propertyValue0, T1? propertyValue1) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1 }); - } + /// + /// Logs a message at the specified log level with two typed property values, checking if logging is enabled first. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, + string? message, T0? propertyValue0, T1? propertyValue1) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1 }); + } - /// - /// Logs a message at the specified log level with three typed property values, checking if logging is enabled first. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, - string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2 }); - } + /// + /// Logs a message at the specified log level with three typed property values, checking if logging is enabled first. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, + string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2 }); + } - /// - /// Logs a message at the specified log level with four typed property values, checking if logging is enabled first. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, - string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3 }); - } + /// + /// Logs a message at the specified log level with four typed property values, checking if logging is enabled first. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, + string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3 }); + } - /// - /// Logs a message at the specified log level with five typed property values, checking if logging is enabled first. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, - string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4 }); - } + /// + /// Logs a message at the specified log level with five typed property values, checking if logging is enabled first. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, + string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4 }); + } - /// - /// Logs a message at the specified log level with six typed property values, checking if logging is enabled first. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log level for the message. - /// The exception associated with the log entry, if any. - /// The log message. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - internal static void LogMessage(this ILogger logger, LogLevel logLevel, Exception? exception, - string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - if (logger.IsEnabled(logLevel)) - logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5 }); + /// + /// Logs a message at the specified log level with six typed property values, checking if logging is enabled first. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log level for the message. + /// The exception associated with the log entry, if any. + /// The log message. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + internal void LogMessage(LogLevel logLevel, Exception? exception, + string? message, T0? propertyValue0, T1? propertyValue1, T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + if (logger.IsEnabled(logLevel)) + logger.Log(logLevel, exception, message, new object?[] { propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5 }); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/PerformanceExtensions.cs b/src/LayeredCraft.StructuredLogging/PerformanceExtensions.cs index 68a8a53..4e676d8 100644 --- a/src/LayeredCraft.StructuredLogging/PerformanceExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/PerformanceExtensions.cs @@ -11,203 +11,201 @@ namespace LayeredCraft.StructuredLogging; /// public static class PerformanceExtensions { - /// - /// Creates a disposable timer that logs the start and completion time of an operation. - /// When disposed, it automatically logs the total elapsed time with structured data. - /// - /// The logger instance. - /// The name of the operation being timed. - /// The log level to use for timing messages. Defaults to Information. - /// An IDisposable TimedOperation that logs completion time when disposed. - /// - /// - /// using (logger.TimeOperation("DatabaseQuery")) - /// { - /// // Database operation code here - /// // Automatically logs start and completion with elapsed time - /// } - /// - /// - public static IDisposable TimeOperation(this ILogger logger, string operationName, LogLevel logLevel = LogLevel.Information) - { - return new TimedOperation(logger, operationName, logLevel); - } - - /// - /// Executes an asynchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. - /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. - /// - /// The return type of the asynchronous operation. /// The logger instance. - /// The name of the operation being timed. - /// The asynchronous operation to execute and time. - /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. - /// The result of the operation. - /// - /// - /// var result = await logger.TimeAsync("FetchUserData", async () => - /// { - /// return await userService.GetUserAsync(userId); - /// }); - /// - /// - public static async Task TimeAsync(this ILogger logger, string operationName, Func> operation, LogLevel logLevel = LogLevel.Information) + extension(ILogger logger) { - var stopwatch = Stopwatch.StartNew(); - logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); - - try - { - var result = await operation(); - stopwatch.Stop(); - logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - return result; - } - catch (Exception ex) + /// + /// Creates a disposable timer that logs the start and completion time of an operation. + /// When disposed, it automatically logs the total elapsed time with structured data. + /// + /// The name of the operation being timed. + /// The log level to use for timing messages. Defaults to Information. + /// An IDisposable TimedOperation that logs completion time when disposed. + /// + /// + /// using (logger.TimeOperation("DatabaseQuery")) + /// { + /// // Database operation code here + /// // Automatically logs start and completion with elapsed time + /// } + /// + /// + public IDisposable TimeOperation(string operationName, LogLevel logLevel = LogLevel.Information) { - stopwatch.Stop(); - logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - throw; + return new TimedOperation(logger, operationName, logLevel); } - } - /// - /// Executes an asynchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. - /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. - /// - /// The logger instance. - /// The name of the operation being timed. - /// The asynchronous operation to execute and time. - /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. - /// A task representing the completion of the operation. - /// - /// - /// await logger.TimeAsync("SendNotification", async () => - /// { - /// await notificationService.SendAsync(notification); - /// }); - /// - /// - public static async Task TimeAsync(this ILogger logger, string operationName, Func operation, LogLevel logLevel = LogLevel.Information) - { - var stopwatch = Stopwatch.StartNew(); - logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); - - try - { - await operation(); - stopwatch.Stop(); - logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - } - catch (Exception ex) + /// + /// Executes an asynchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. + /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. + /// + /// The return type of the asynchronous operation. + /// The name of the operation being timed. + /// The asynchronous operation to execute and time. + /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. + /// The result of the operation. + /// + /// + /// var result = await logger.TimeAsync("FetchUserData", async () => + /// { + /// return await userService.GetUserAsync(userId); + /// }); + /// + /// + public async Task TimeAsync(string operationName, Func> operation, LogLevel logLevel = LogLevel.Information) { - stopwatch.Stop(); - logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - throw; + var stopwatch = Stopwatch.StartNew(); + logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); + + try + { + var result = await operation(); + stopwatch.Stop(); + logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + return result; + } + catch (Exception ex) + { + stopwatch.Stop(); + logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + throw; + } } - } - /// - /// Executes a synchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. - /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. - /// - /// The return type of the operation. - /// The logger instance. - /// The name of the operation being timed. - /// The synchronous operation to execute and time. - /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. - /// The result of the operation. - /// - /// - /// var result = logger.Time("CalculateSum", () => - /// { - /// return numbers.Sum(); - /// }); - /// - /// - public static TResult Time(this ILogger logger, string operationName, Func operation, LogLevel logLevel = LogLevel.Information) - { - var stopwatch = Stopwatch.StartNew(); - logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); - - try + /// + /// Executes an asynchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. + /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. + /// + /// The name of the operation being timed. + /// The asynchronous operation to execute and time. + /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. + /// A task representing the completion of the operation. + /// + /// + /// await logger.TimeAsync("SendNotification", async () => + /// { + /// await notificationService.SendAsync(notification); + /// }); + /// + /// + public async Task TimeAsync(string operationName, Func operation, LogLevel logLevel = LogLevel.Information) { - var result = operation(); - stopwatch.Stop(); - logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - return result; + var stopwatch = Stopwatch.StartNew(); + logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); + + try + { + await operation(); + stopwatch.Stop(); + logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + } + catch (Exception ex) + { + stopwatch.Stop(); + logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + throw; + } } - catch (Exception ex) + + /// + /// Executes a synchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. + /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. + /// + /// The return type of the operation. + /// The name of the operation being timed. + /// The synchronous operation to execute and time. + /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. + /// The result of the operation. + /// + /// + /// var result = logger.Time("CalculateSum", () => + /// { + /// return numbers.Sum(); + /// }); + /// + /// + public TResult Time(string operationName, Func operation, LogLevel logLevel = LogLevel.Information) { - stopwatch.Stop(); - logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - throw; + var stopwatch = Stopwatch.StartNew(); + logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); + + try + { + var result = operation(); + stopwatch.Stop(); + logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + return result; + } + catch (Exception ex) + { + stopwatch.Stop(); + logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + throw; + } } - } - /// - /// Executes a synchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. - /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. - /// - /// The logger instance. - /// The name of the operation being timed. - /// The synchronous operation to execute and time. - /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. - /// - /// - /// logger.Time("UpdateCache", () => - /// { - /// cache.Update(data); - /// }); - /// - /// - public static void Time(this ILogger logger, string operationName, Action operation, LogLevel logLevel = LogLevel.Information) - { - var stopwatch = Stopwatch.StartNew(); - logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); - - try + /// + /// Executes a synchronous operation with automatic timing and logging. Logs start, completion, and elapsed time. + /// If the operation throws an exception, logs the failure with timing information and re-throws the exception. + /// + /// The name of the operation being timed. + /// The synchronous operation to execute and time. + /// The log level to use for success timing messages. Defaults to Information. Errors are always logged at Error level. + /// + /// + /// logger.Time("UpdateCache", () => + /// { + /// cache.Update(data); + /// }); + /// + /// + public void Time(string operationName, Action operation, LogLevel logLevel = LogLevel.Information) { - operation(); - stopwatch.Stop(); - logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + var stopwatch = Stopwatch.StartNew(); + logger.LogMessage(logLevel, null, "Starting operation: {OperationName}", operationName); + + try + { + operation(); + stopwatch.Stop(); + logger.LogMessage(logLevel, null, "Completed operation: {OperationName} in {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + } + catch (Exception ex) + { + stopwatch.Stop(); + logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); + throw; + } } - catch (Exception ex) + + /// + /// Creates a disposable timer for the current method using automatic caller information. + /// This is useful for timing method execution without manually specifying the method name. + /// + /// The log level to use for timing messages. Defaults to Debug. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// An IDisposable TimedOperation that logs method completion time when disposed. + /// + /// + /// public void ProcessData() + /// { + /// using (logger.TimeMethod()) + /// { + /// // Method implementation + /// // Automatically logs "ClassName.ProcessData" timing + /// } + /// } + /// + /// + public IDisposable TimeMethod(LogLevel logLevel = LogLevel.Debug, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "") { - stopwatch.Stop(); - logger.LogMessage(LogLevel.Error, ex, "Failed operation: {OperationName} after {ElapsedMilliseconds}ms", operationName, stopwatch.ElapsedMilliseconds); - throw; + var fileName = Path.GetFileNameWithoutExtension(filePath); + return new TimedOperation(logger, $"{fileName}.{memberName}", logLevel); } } - - /// - /// Creates a disposable timer for the current method using automatic caller information. - /// This is useful for timing method execution without manually specifying the method name. - /// - /// The logger instance. - /// The log level to use for timing messages. Defaults to Debug. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// An IDisposable TimedOperation that logs method completion time when disposed. - /// - /// - /// public void ProcessData() - /// { - /// using (logger.TimeMethod()) - /// { - /// // Method implementation - /// // Automatically logs "ClassName.ProcessData" timing - /// } - /// } - /// - /// - public static IDisposable TimeMethod(this ILogger logger, LogLevel logLevel = LogLevel.Debug, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "") - { - var fileName = Path.GetFileNameWithoutExtension(filePath); - return new TimedOperation(logger, $"{fileName}.{memberName}", logLevel); - } } /// diff --git a/src/LayeredCraft.StructuredLogging/ScopeExtensions.cs b/src/LayeredCraft.StructuredLogging/ScopeExtensions.cs index b5ee203..6b879f6 100644 --- a/src/LayeredCraft.StructuredLogging/ScopeExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/ScopeExtensions.cs @@ -11,350 +11,341 @@ namespace LayeredCraft.StructuredLogging; /// public static class ScopeExtensions { - /// - /// Creates a logging scope with a single named typed property that will be included in all log entries within the scope. - /// - /// The type of the property value. /// The logger instance. - /// The name of the property to add to the scope. - /// The value of the property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginScope("UserId", userId)) - /// { - /// logger.LogInformation("User operation completed"); // Will include UserId property - /// } - /// - /// - public static IDisposable BeginScope(this ILogger logger, string name, T value) + extension(ILogger logger) { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with a single named typed property that will be included in all log entries within the scope. + /// + /// The type of the property value. + /// The name of the property to add to the scope. + /// The value of the property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginScope("UserId", userId)) + /// { + /// logger.LogInformation("User operation completed"); // Will include UserId property + /// } + /// + /// + public IDisposable BeginScope(string name, T value) { - [name] = value - }); - } + return logger.BeginScope(new Dictionary + { + [name] = value + }); + } - /// - /// Creates a logging scope with two named typed properties that will be included in all log entries within the scope. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The name of the first property to add to the scope. - /// The value of the first property to add to the scope. - /// The name of the second property to add to the scope. - /// The value of the second property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginScope("UserId", userId, "RequestId", requestId)) - /// { - /// logger.LogInformation("Processing request"); // Will include both UserId and RequestId properties - /// } - /// - /// - public static IDisposable BeginScope(this ILogger logger, string name0, T0 value0, string name1, T1 value1) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with two named typed properties that will be included in all log entries within the scope. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The name of the first property to add to the scope. + /// The value of the first property to add to the scope. + /// The name of the second property to add to the scope. + /// The value of the second property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginScope("UserId", userId, "RequestId", requestId)) + /// { + /// logger.LogInformation("Processing request"); // Will include both UserId and RequestId properties + /// } + /// + /// + public IDisposable BeginScope(string name0, T0 value0, string name1, T1 value1) { - [name0] = value0, - [name1] = value1 - }); - } + return logger.BeginScope(new Dictionary + { + [name0] = value0, + [name1] = value1 + }); + } - /// - /// Creates a logging scope with three named typed properties that will be included in all log entries within the scope. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The name of the first property to add to the scope. - /// The value of the first property to add to the scope. - /// The name of the second property to add to the scope. - /// The value of the second property to add to the scope. - /// The name of the third property to add to the scope. - /// The value of the third property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - public static IDisposable BeginScope(this ILogger logger, string name0, T0 value0, string name1, T1 value1, string name2, T2 value2) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with three named typed properties that will be included in all log entries within the scope. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The name of the first property to add to the scope. + /// The value of the first property to add to the scope. + /// The name of the second property to add to the scope. + /// The value of the second property to add to the scope. + /// The name of the third property to add to the scope. + /// The value of the third property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + public IDisposable BeginScope(string name0, T0 value0, string name1, T1 value1, string name2, T2 value2) { - [name0] = value0, - [name1] = value1, - [name2] = value2 - }); - } + return logger.BeginScope(new Dictionary + { + [name0] = value0, + [name1] = value1, + [name2] = value2 + }); + } - /// - /// Creates a logging scope with four named typed properties that will be included in all log entries within the scope. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The name of the first property to add to the scope. - /// The value of the first property to add to the scope. - /// The name of the second property to add to the scope. - /// The value of the second property to add to the scope. - /// The name of the third property to add to the scope. - /// The value of the third property to add to the scope. - /// The name of the fourth property to add to the scope. - /// The value of the fourth property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - public static IDisposable BeginScope(this ILogger logger, string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with four named typed properties that will be included in all log entries within the scope. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The name of the first property to add to the scope. + /// The value of the first property to add to the scope. + /// The name of the second property to add to the scope. + /// The value of the second property to add to the scope. + /// The name of the third property to add to the scope. + /// The value of the third property to add to the scope. + /// The name of the fourth property to add to the scope. + /// The value of the fourth property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + public IDisposable BeginScope(string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3) { - [name0] = value0, - [name1] = value1, - [name2] = value2, - [name3] = value3 - }); - } + return logger.BeginScope(new Dictionary + { + [name0] = value0, + [name1] = value1, + [name2] = value2, + [name3] = value3 + }); + } - /// - /// Creates a logging scope with five named typed properties that will be included in all log entries within the scope. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The name of the first property to add to the scope. - /// The value of the first property to add to the scope. - /// The name of the second property to add to the scope. - /// The value of the second property to add to the scope. - /// The name of the third property to add to the scope. - /// The value of the third property to add to the scope. - /// The name of the fourth property to add to the scope. - /// The value of the fourth property to add to the scope. - /// The name of the fifth property to add to the scope. - /// The value of the fifth property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - public static IDisposable BeginScope(this ILogger logger, string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3, string name4, T4 value4) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with five named typed properties that will be included in all log entries within the scope. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The name of the first property to add to the scope. + /// The value of the first property to add to the scope. + /// The name of the second property to add to the scope. + /// The value of the second property to add to the scope. + /// The name of the third property to add to the scope. + /// The value of the third property to add to the scope. + /// The name of the fourth property to add to the scope. + /// The value of the fourth property to add to the scope. + /// The name of the fifth property to add to the scope. + /// The value of the fifth property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + public IDisposable BeginScope(string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3, string name4, T4 value4) { - [name0] = value0, - [name1] = value1, - [name2] = value2, - [name3] = value3, - [name4] = value4 - }); - } + return logger.BeginScope(new Dictionary + { + [name0] = value0, + [name1] = value1, + [name2] = value2, + [name3] = value3, + [name4] = value4 + }); + } - /// - /// Creates a logging scope with six named typed properties that will be included in all log entries within the scope. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The name of the first property to add to the scope. - /// The value of the first property to add to the scope. - /// The name of the second property to add to the scope. - /// The value of the second property to add to the scope. - /// The name of the third property to add to the scope. - /// The value of the third property to add to the scope. - /// The name of the fourth property to add to the scope. - /// The value of the fourth property to add to the scope. - /// The name of the fifth property to add to the scope. - /// The value of the fifth property to add to the scope. - /// The name of the sixth property to add to the scope. - /// The value of the sixth property to add to the scope. - /// An IDisposable that should be disposed to end the scope. - public static IDisposable BeginScope(this ILogger logger, string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3, string name4, T4 value4, string name5, T5 value5) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope with six named typed properties that will be included in all log entries within the scope. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The name of the first property to add to the scope. + /// The value of the first property to add to the scope. + /// The name of the second property to add to the scope. + /// The value of the second property to add to the scope. + /// The name of the third property to add to the scope. + /// The value of the third property to add to the scope. + /// The name of the fourth property to add to the scope. + /// The value of the fourth property to add to the scope. + /// The name of the fifth property to add to the scope. + /// The value of the fifth property to add to the scope. + /// The name of the sixth property to add to the scope. + /// The value of the sixth property to add to the scope. + /// An IDisposable that should be disposed to end the scope. + public IDisposable BeginScope(string name0, T0 value0, string name1, T1 value1, string name2, T2 value2, string name3, T3 value3, string name4, T4 value4, string name5, T5 value5) { - [name0] = value0, - [name1] = value1, - [name2] = value2, - [name3] = value3, - [name4] = value4, - [name5] = value5 - }); - } + return logger.BeginScope(new Dictionary + { + [name0] = value0, + [name1] = value1, + [name2] = value2, + [name3] = value3, + [name4] = value4, + [name5] = value5 + }); + } - /// - /// Creates a logging scope that automatically includes caller information (method name, file path, and line number) - /// in all log entries within the scope. This is useful for debugging and tracing. - /// - /// The logger instance. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginCallerScope()) - /// { - /// logger.LogInformation("Operation started"); // Will include MemberName, FileName, FilePath, and LineNumber - /// } - /// - /// - public static IDisposable BeginCallerScope(this ILogger logger, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope that automatically includes caller information (method name, file path, and line number) + /// in all log entries within the scope. This is useful for debugging and tracing. + /// + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginCallerScope()) + /// { + /// logger.LogInformation("Operation started"); // Will include MemberName, FileName, FilePath, and LineNumber + /// } + /// + /// + public IDisposable BeginCallerScope([CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) { - ["MemberName"] = memberName, - ["FileName"] = Path.GetFileName(filePath), - ["FilePath"] = filePath, - ["LineNumber"] = lineNumber - }); - } + return logger.BeginScope(new Dictionary + { + ["MemberName"] = memberName, + ["FileName"] = Path.GetFileName(filePath), + ["FilePath"] = filePath, + ["LineNumber"] = lineNumber + }); + } - /// - /// Creates a logging scope that includes both a custom typed property and automatic caller information - /// (method name, file path, and line number) in all log entries within the scope. - /// - /// The type of the custom property value. - /// The logger instance. - /// The name of the custom property to add to the scope. - /// The value of the custom property to add to the scope. - /// The name of the calling member. This is automatically populated by the compiler. - /// The path of the source file containing the caller. This is automatically populated by the compiler. - /// The line number in the source file where this method is called. This is automatically populated by the compiler. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginCallerScope("UserId", userId)) - /// { - /// logger.LogInformation("User operation started"); // Will include UserId plus caller info - /// } - /// - /// - public static IDisposable BeginCallerScope(this ILogger logger, string name, T value, - [CallerMemberName] string memberName = "", - [CallerFilePath] string filePath = "", - [CallerLineNumber] int lineNumber = 0) - { - return logger.BeginScope(new Dictionary + /// + /// Creates a logging scope that includes both a custom typed property and automatic caller information + /// (method name, file path, and line number) in all log entries within the scope. + /// + /// The type of the custom property value. + /// The name of the custom property to add to the scope. + /// The value of the custom property to add to the scope. + /// The name of the calling member. This is automatically populated by the compiler. + /// The path of the source file containing the caller. This is automatically populated by the compiler. + /// The line number in the source file where this method is called. This is automatically populated by the compiler. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginCallerScope("UserId", userId)) + /// { + /// logger.LogInformation("User operation started"); // Will include UserId plus caller info + /// } + /// + /// + public IDisposable BeginCallerScope(string name, T value, + [CallerMemberName] string memberName = "", + [CallerFilePath] string filePath = "", + [CallerLineNumber] int lineNumber = 0) { - [name] = value, - ["MemberName"] = memberName, - ["FileName"] = Path.GetFileName(filePath), - ["FilePath"] = filePath, - ["LineNumber"] = lineNumber - }); - } + return logger.BeginScope(new Dictionary + { + [name] = value, + ["MemberName"] = memberName, + ["FileName"] = Path.GetFileName(filePath), + ["FilePath"] = filePath, + ["LineNumber"] = lineNumber + }); + } - /// - /// Creates a logging scope for web request correlation, adding RequestId and optionally UserId - /// to all log entries within the scope. This is particularly useful for web applications. - /// - /// The logger instance. - /// The unique identifier for the current request. - /// The optional user identifier associated with the request. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginRequestScope(HttpContext.TraceIdentifier, user.Id)) - /// { - /// logger.LogInformation("Processing user request"); // Will include RequestId and UserId - /// } - /// - /// - public static IDisposable BeginRequestScope(this ILogger logger, string requestId, string? userId = null) - { - var scope = new Dictionary + /// + /// Creates a logging scope for web request correlation, adding RequestId and optionally UserId + /// to all log entries within the scope. This is particularly useful for web applications. + /// + /// The unique identifier for the current request. + /// The optional user identifier associated with the request. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginRequestScope(HttpContext.TraceIdentifier, user.Id)) + /// { + /// logger.LogInformation("Processing user request"); // Will include RequestId and UserId + /// } + /// + /// + public IDisposable BeginRequestScope(string requestId, string? userId = null) { - ["RequestId"] = requestId - }; + var scope = new Dictionary + { + ["RequestId"] = requestId + }; - if (userId != null) - scope["UserId"] = userId; + if (userId != null) + scope["UserId"] = userId; - return logger.BeginScope(scope); - } + return logger.BeginScope(scope); + } - /// - /// Creates a logging scope for operation tracking, adding OperationName and OperationId - /// to all log entries within the scope. If no operationId is provided, a new GUID is generated. - /// - /// The logger instance. - /// The name of the operation being performed. - /// The optional unique identifier for the operation. If null, a new GUID is generated. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginOperationScope("ProcessPayment")) - /// { - /// logger.LogInformation("Payment processing started"); // Will include OperationName and auto-generated OperationId - /// } - /// - /// - public static IDisposable BeginOperationScope(this ILogger logger, string operationName, string? operationId = null) - { - var scope = new Dictionary + /// + /// Creates a logging scope for operation tracking, adding OperationName and OperationId + /// to all log entries within the scope. If no operationId is provided, a new GUID is generated. + /// + /// The name of the operation being performed. + /// The optional unique identifier for the operation. If null, a new GUID is generated. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginOperationScope("ProcessPayment")) + /// { + /// logger.LogInformation("Payment processing started"); // Will include OperationName and auto-generated OperationId + /// } + /// + /// + public IDisposable BeginOperationScope(string operationName, string? operationId = null) { - ["OperationName"] = operationName - }; + var scope = new Dictionary + { + ["OperationName"] = operationName + }; - if (operationId != null) - scope["OperationId"] = operationId; - else - scope["OperationId"] = Guid.NewGuid().ToString(); + if (operationId != null) + scope["OperationId"] = operationId; + else + scope["OperationId"] = Guid.NewGuid().ToString(); - return logger.BeginScope(scope); - } + return logger.BeginScope(scope); + } - /// - /// Creates a logging scope for distributed tracing correlation, adding CorrelationId and optionally ParentId - /// to all log entries within the scope. This is useful for tracking requests across multiple services. - /// - /// The logger instance. - /// The correlation identifier that tracks the request across services. - /// The optional parent identifier for hierarchical request tracking. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginCorrelationScope(traceId, parentSpanId)) - /// { - /// logger.LogInformation("Service operation started"); // Will include CorrelationId and ParentId - /// } - /// - /// - public static IDisposable BeginCorrelationScope(this ILogger logger, string correlationId, string? parentId = null) - { - var scope = new Dictionary + /// + /// Creates a logging scope for distributed tracing correlation, adding CorrelationId and optionally ParentId + /// to all log entries within the scope. This is useful for tracking requests across multiple services. + /// + /// The correlation identifier that tracks the request across services. + /// The optional parent identifier for hierarchical request tracking. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginCorrelationScope(traceId, parentSpanId)) + /// { + /// logger.LogInformation("Service operation started"); // Will include CorrelationId and ParentId + /// } + /// + /// + public IDisposable BeginCorrelationScope(string correlationId, string? parentId = null) { - ["CorrelationId"] = correlationId - }; + var scope = new Dictionary + { + ["CorrelationId"] = correlationId + }; - if (parentId != null) - scope["ParentId"] = parentId; + if (parentId != null) + scope["ParentId"] = parentId; - return logger.BeginScope(scope); - } + return logger.BeginScope(scope); + } - /// - /// Creates a logging scope using an anonymous object, where all public properties of the object - /// will be included as structured data in all log entries within the scope. - /// - /// The logger instance. - /// An anonymous object containing the properties to include in the scope. - /// An IDisposable that should be disposed to end the scope. - /// - /// - /// using (logger.BeginScopeWith(new { UserId = userId, SessionId = sessionId, TenantId = tenantId })) - /// { - /// logger.LogInformation("User session started"); // Will include UserId, SessionId, and TenantId - /// } - /// - /// - public static IDisposable BeginScopeWith(this ILogger logger, object state) - { - return logger.BeginScope(state); + /// + /// Creates a logging scope using an anonymous object, where all public properties of the object + /// will be included as structured data in all log entries within the scope. + /// + /// An anonymous object containing the properties to include in the scope. + /// An IDisposable that should be disposed to end the scope. + /// + /// + /// using (logger.BeginScopeWith(new { UserId = userId, SessionId = sessionId, TenantId = tenantId })) + /// { + /// logger.LogInformation("User session started"); // Will include UserId, SessionId, and TenantId + /// } + /// + /// + public IDisposable BeginScopeWith(object state) + { + return logger.BeginScope(state); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/VerboseExtensions.cs b/src/LayeredCraft.StructuredLogging/VerboseExtensions.cs index 20b83b2..b48de7e 100644 --- a/src/LayeredCraft.StructuredLogging/VerboseExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/VerboseExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class VerboseExtensions { - /// - /// Logs a verbose-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Verbose("Method entry: ProcessOrder"); - /// - /// - public static void Verbose(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Trace, null, message); - } + /// + /// Logs a verbose-level message. + /// + /// The log message. + /// + /// + /// logger.Verbose("Method entry: ProcessOrder"); + /// + /// + public void Verbose(string? message) + { + logger.LogMessage(LogLevel.Trace, null, message); + } - /// - /// Logs a verbose-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Verbose("Variable state: counter = {Counter}", counter); - /// - /// - public static void Verbose(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue); - } + /// + /// Logs a verbose-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Verbose("Variable state: counter = {Counter}", counter); + /// + /// + public void Verbose(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue); + } - /// - /// Logs a verbose-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Verbose("Loop iteration {Index} processing item {ItemId}", index, itemId); - /// - /// - public static void Verbose(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs a verbose-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Verbose("Loop iteration {Index} processing item {ItemId}", index, itemId); + /// + /// + public void Verbose(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs a verbose-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Verbose("Method {Method} executed with {ParameterCount} parameters in {Duration}ms", methodName, paramCount, duration); - /// - /// - public static void Verbose(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a verbose-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Verbose("Method {Method} executed with {ParameterCount} parameters in {Duration}ms", methodName, paramCount, duration); + /// + /// + public void Verbose(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a verbose-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Verbose("Memory allocation: {Size} bytes at {Address} for {Type} in {Region}", size, address, typeName, region); - /// - /// - public static void Verbose(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a verbose-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Verbose("Memory allocation: {Size} bytes at {Address} for {Type} in {Region}", size, address, typeName, region); + /// + /// + public void Verbose(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a verbose-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Verbose("Network packet {Type} from {Source} to {Destination} size {Size} at {Timestamp}", packetType, source, destination, size, timestamp); - /// - /// - public static void Verbose(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a verbose-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Verbose("Network packet {Type} from {Source} to {Destination} size {Size} at {Timestamp}", packetType, source, destination, size, timestamp); + /// + /// + public void Verbose(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a verbose-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Verbose("SQL query {Query} on table {Table} in schema {Schema} by user {User} from {Host} took {Duration}ms", query, table, schema, user, host, duration); - /// - /// - public static void Verbose(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs a verbose-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Verbose("SQL query {Query} on table {Table} in schema {Schema} by user {User} from {Host} took {Duration}ms", query, table, schema, user, host, duration); + /// + /// + public void Verbose(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Trace, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs a verbose-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Verbose(exception, "Exception occurred during detailed processing"); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Trace, exception, message); - } + /// + /// Logs a verbose-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Verbose(exception, "Exception occurred during detailed processing"); + /// + /// + public void Verbose(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Trace, exception, message); + } - /// - /// Logs a verbose-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "Variable state at exception: counter = {Counter}", counter); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue); - } + /// + /// Logs a verbose-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "Variable state at exception: counter = {Counter}", counter); + /// + /// + public void Verbose(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue); + } - /// - /// Logs a verbose-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "Loop failed at iteration {Index} processing item {ItemId}", index, itemId); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs a verbose-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "Loop failed at iteration {Index} processing item {ItemId}", index, itemId); + /// + /// + public void Verbose(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs a verbose-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "Method {Method} failed with {ParameterCount} parameters after {Duration}ms", methodName, paramCount, duration); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a verbose-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "Method {Method} failed with {ParameterCount} parameters after {Duration}ms", methodName, paramCount, duration); + /// + /// + public void Verbose(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a verbose-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "Memory allocation failed: {Size} bytes at {Address} for {Type} in {Region}", size, address, typeName, region); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a verbose-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "Memory allocation failed: {Size} bytes at {Address} for {Type} in {Region}", size, address, typeName, region); + /// + /// + public void Verbose(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a verbose-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "Network packet {Type} send failed from {Source} to {Destination} size {Size} at {Timestamp}", packetType, source, destination, size, timestamp); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a verbose-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "Network packet {Type} send failed from {Source} to {Destination} size {Size} at {Timestamp}", packetType, source, destination, size, timestamp); + /// + /// + public void Verbose(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a verbose-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Verbose(exception, "SQL query {Query} failed on table {Table} in schema {Schema} by user {User} from {Host} after {Duration}ms", query, table, schema, user, host, duration); - /// - /// - public static void Verbose(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs a verbose-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Verbose(exception, "SQL query {Query} failed on table {Table} in schema {Schema} by user {User} from {Host} after {Duration}ms", query, table, schema, user, host, duration); + /// + /// + public void Verbose(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Trace, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file diff --git a/src/LayeredCraft.StructuredLogging/WarningExtensions.cs b/src/LayeredCraft.StructuredLogging/WarningExtensions.cs index 4798361..742803d 100644 --- a/src/LayeredCraft.StructuredLogging/WarningExtensions.cs +++ b/src/LayeredCraft.StructuredLogging/WarningExtensions.cs @@ -8,312 +8,302 @@ namespace LayeredCraft.StructuredLogging; /// public static class WarningExtensions { - /// - /// Logs a warning-level message. - /// /// The logger instance. - /// The log message. - /// - /// - /// logger.Warning("Configuration setting is deprecated"); - /// - /// - public static void Warning(this ILogger logger, string? message) + extension(ILogger logger) { - logger.LogMessage(LogLevel.Warning, null, message); - } + /// + /// Logs a warning-level message. + /// + /// The log message. + /// + /// + /// logger.Warning("Configuration setting is deprecated"); + /// + /// + public void Warning(string? message) + { + logger.LogMessage(LogLevel.Warning, null, message); + } - /// - /// Logs a warning-level message with one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Warning("Retry attempt {RetryCount} exceeded recommended limit", retryCount); - /// - /// - public static void Warning(this ILogger logger, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue); - } + /// + /// Logs a warning-level message with one typed property value. + /// + /// The type of the property value. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Warning("Retry attempt {RetryCount} exceeded recommended limit", retryCount); + /// + /// + public void Warning(string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue); + } - /// - /// Logs a warning-level message with two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Warning("User {UserId} exceeded rate limit of {MaxRequests} requests per minute", userId, maxRequests); - /// - /// - public static void Warning(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1); - } + /// + /// Logs a warning-level message with two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Warning("User {UserId} exceeded rate limit of {MaxRequests} requests per minute", userId, maxRequests); + /// + /// + public void Warning(string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1); + } - /// - /// Logs a warning-level message with three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Warning("API response time {Duration}ms for {Endpoint} exceeded threshold of {Threshold}ms", duration, endpoint, threshold); - /// - /// - public static void Warning(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a warning-level message with three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Warning("API response time {Duration}ms for {Endpoint} exceeded threshold of {Threshold}ms", duration, endpoint, threshold); + /// + /// + public void Warning(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a warning-level message with four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Warning("Memory usage {CurrentMemory}MB on {ServerName} is approaching limit of {MaxMemory}MB at {Percentage}%", currentMemory, serverName, maxMemory, percentage); - /// - /// - public static void Warning(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a warning-level message with four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Warning("Memory usage {CurrentMemory}MB on {ServerName} is approaching limit of {MaxMemory}MB at {Percentage}%", currentMemory, serverName, maxMemory, percentage); + /// + /// + public void Warning(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a warning-level message with five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Warning("Queue {QueueName} on {ServerName} has {CurrentSize} items, approaching limit of {MaxSize} with {UsagePercent}% usage", queueName, serverName, currentSize, maxSize, usagePercent); - /// - /// - public static void Warning(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a warning-level message with five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Warning("Queue {QueueName} on {ServerName} has {CurrentSize} items, approaching limit of {MaxSize} with {UsagePercent}% usage", queueName, serverName, currentSize, maxSize, usagePercent); + /// + /// + public void Warning(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a warning-level message with six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Warning("Connection pool {PoolName} on {ServerName} in {Region} has {ActiveConnections} active of {MaxConnections} max with {IdleConnections} idle connections", poolName, serverName, region, activeConnections, maxConnections, idleConnections); - /// - /// - public static void Warning(this ILogger logger, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); - } + /// + /// Logs a warning-level message with six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Warning("Connection pool {PoolName} on {ServerName} in {Region} has {ActiveConnections} active of {MaxConnections} max with {IdleConnections} idle connections", poolName, serverName, region, activeConnections, maxConnections, idleConnections); + /// + /// + public void Warning(string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Warning, null, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } - /// - /// Logs a warning-level message with an associated exception. - /// - /// The logger instance. - /// The exception associated with the log entry. - /// The log message. - /// - /// - /// logger.Warning(exception, "Non-critical operation failed but system continues"); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message) - { - logger.LogMessage(LogLevel.Warning, exception, message); - } + /// + /// Logs a warning-level message with an associated exception. + /// + /// The exception associated with the log entry. + /// The log message. + /// + /// + /// logger.Warning(exception, "Non-critical operation failed but system continues"); + /// + /// + public void Warning(Exception? exception, string? message) + { + logger.LogMessage(LogLevel.Warning, exception, message); + } - /// - /// Logs a warning-level message with an associated exception and one typed property value. - /// - /// The type of the property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "Retry attempt {RetryCount} failed but will continue", retryCount); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T? propertyValue) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue); - } + /// + /// Logs a warning-level message with an associated exception and one typed property value. + /// + /// The type of the property value. + /// The exception associated with the log entry. + /// The log message template. + /// The property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "Retry attempt {RetryCount} failed but will continue", retryCount); + /// + /// + public void Warning(Exception? exception, string? message, T? propertyValue) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue); + } - /// - /// Logs a warning-level message with an associated exception and two typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "User {UserId} rate limit exceeded with {RequestCount} requests but request allowed", userId, requestCount); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1); - } + /// + /// Logs a warning-level message with an associated exception and two typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "User {UserId} rate limit exceeded with {RequestCount} requests but request allowed", userId, requestCount); + /// + /// + public void Warning(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1); + } - /// - /// Logs a warning-level message with an associated exception and three typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "API timeout after {Duration}ms for {Endpoint} but fallback used with status {StatusCode}", duration, endpoint, statusCode); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2); - } + /// + /// Logs a warning-level message with an associated exception and three typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "API timeout after {Duration}ms for {Endpoint} but fallback used with status {StatusCode}", duration, endpoint, statusCode); + /// + /// + public void Warning(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2); + } - /// - /// Logs a warning-level message with an associated exception and four typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "Memory warning: {CurrentMemory}MB on {ServerName} approaching {MaxMemory}MB limit at {Percentage}%", currentMemory, serverName, maxMemory, percentage); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); - } + /// + /// Logs a warning-level message with an associated exception and four typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "Memory warning: {CurrentMemory}MB on {ServerName} approaching {MaxMemory}MB limit at {Percentage}%", currentMemory, serverName, maxMemory, percentage); + /// + /// + public void Warning(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3); + } - /// - /// Logs a warning-level message with an associated exception and five typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "Queue warning: {QueueName} on {ServerName} has {CurrentSize} items approaching {MaxSize} limit with {UsagePercent}% usage", queueName, serverName, currentSize, maxSize, usagePercent); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); - } + /// + /// Logs a warning-level message with an associated exception and five typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "Queue warning: {QueueName} on {ServerName} has {CurrentSize} items approaching {MaxSize} limit with {UsagePercent}% usage", queueName, serverName, currentSize, maxSize, usagePercent); + /// + /// + public void Warning(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4); + } - /// - /// Logs a warning-level message with an associated exception and six typed property values. - /// - /// The type of the first property value. - /// The type of the second property value. - /// The type of the third property value. - /// The type of the fourth property value. - /// The type of the fifth property value. - /// The type of the sixth property value. - /// The logger instance. - /// The exception associated with the log entry. - /// The log message template. - /// The first property value to include in the log entry. - /// The second property value to include in the log entry. - /// The third property value to include in the log entry. - /// The fourth property value to include in the log entry. - /// The fifth property value to include in the log entry. - /// The sixth property value to include in the log entry. - /// - /// - /// logger.Warning(exception, "Connection pool warning: {PoolName} on {ServerName} in {Region} has {ActiveConnections} active of {MaxConnections} max with {IdleConnections} idle", poolName, serverName, region, activeConnections, maxConnections, idleConnections); - /// - /// - public static void Warning(this ILogger logger, Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, - T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) - { - logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + /// + /// Logs a warning-level message with an associated exception and six typed property values. + /// + /// The type of the first property value. + /// The type of the second property value. + /// The type of the third property value. + /// The type of the fourth property value. + /// The type of the fifth property value. + /// The type of the sixth property value. + /// The exception associated with the log entry. + /// The log message template. + /// The first property value to include in the log entry. + /// The second property value to include in the log entry. + /// The third property value to include in the log entry. + /// The fourth property value to include in the log entry. + /// The fifth property value to include in the log entry. + /// The sixth property value to include in the log entry. + /// + /// + /// logger.Warning(exception, "Connection pool warning: {PoolName} on {ServerName} in {Region} has {ActiveConnections} active of {MaxConnections} max with {IdleConnections} idle", poolName, serverName, region, activeConnections, maxConnections, idleConnections); + /// + /// + public void Warning(Exception? exception, string? message, T0? propertyValue0, T1? propertyValue1, + T2? propertyValue2, T3? propertyValue3, T4? propertyValue4, T5? propertyValue5) + { + logger.LogMessage(LogLevel.Warning, exception, message, propertyValue0, propertyValue1, propertyValue2, propertyValue3, propertyValue4, propertyValue5); + } } } \ No newline at end of file