diff --git a/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.csproj b/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.csproj index 90acf84..81a6706 100644 --- a/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.csproj +++ b/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.csproj @@ -26,7 +26,7 @@ snupkg net9.0 AStar.Dev.Logging.Extensions - 0.5.4 + 0.5.5 diff --git a/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.xml b/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.xml index c5f5c62..cd616eb 100644 --- a/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.xml +++ b/src/AStar.Dev.Logging.Extensions/AStar.Dev.Logging.Extensions.xml @@ -6,285 +6,220 @@ - The - - class exists solely to collect the currently defined EventIds in one place to aid comprehension of the supported Ids - The - - class exists (along with the nested classes) to expose the supported Ids for public consumption, grouped together into logical "chunks" + The class exists solely to collect the currently defined EventIds in one place to aid comprehension of the supported Ids + The class exists (along with the nested classes) to expose the supported Ids for public consumption, grouped together into logical "chunks" - The - - class contains the defined - - events available for logging - Stand-alone - - events can be defined but care should be taken to avoid reusing the values used here + The class contains the defined events available for logging + Stand-alone events can be defined but care should be taken to avoid reusing the values used here - The - - class contains the defined - - events available for logging - Stand-alone - - events can be defined but care should be taken to avoid reusing the values used here + The class contains the defined events available for logging + Stand-alone events can be defined but care should be taken to avoid reusing the values used here - The - - class contains the defined - - events available for logging - Stand-alone - - events can be defined but care should be taken to avoid reusing the values used here + The class contains the defined events available for logging + Stand-alone events can be defined but care should be taken to avoid reusing the values used here - The - - class defines, yep, the EventIds for logging API-related errors + The class defines, yep, the EventIds for logging API-related errors - Gets the - - preconfigured for logging a HealthCheck start + Gets the preconfigured for logging a HealthCheck start - Gets the - - preconfigured for logging a HealthCheck success + Gets the preconfigured for logging a HealthCheck success - Gets the - - preconfigured for logging a HealthCheck warning + Gets the preconfigured for logging a HealthCheck warning - Gets the - - preconfigured for logging a HealthCheck failure + Gets the preconfigured for logging a HealthCheck failure - Gets the - - preconfigured for logging an API Call success + Gets the preconfigured for logging an API Call success - Gets the - - preconfigured for logging an API Call success + Gets the preconfigured for logging an API Call success - Gets the - - preconfigured for logging an API Call warning + Gets the preconfigured for logging an API Call warning - Gets the - - preconfigured for logging an API Call failure + Gets the preconfigured for logging an API Call failure - The - - class defines, yep, the EventIds for logging Common (shared) errors + The class defines, yep, the EventIds for logging Common (shared) errors - Gets the - - preconfigured for logging an error + Gets the preconfigured for logging an error - Gets the - - preconfigured for logging a critical error + Gets the preconfigured for logging a critical error + + + + + Gets the preconfigured for logging a critical error + + + + + Gets the preconfigured for logging a critical error - The - - class defines, yep, the EventIds for logging UI-related errors + The class defines, yep, the EventIds for logging UI-related errors - Gets the - - preconfigured for logging a page view + Gets the preconfigured for logging a page view - The - - class supplies the currently supported, predefined, Log Messages. - There is an additional - - method for any currently not implemented log message - - The underlying instance of - - that will perform the actual logging - - An instance of the - - to perform the Application Insights-specific logging (e.g.: Page View) - + The class supplies the currently supported, predefined, Log Messages. + There is an additional method for any currently not implemented log message + + The underlying instance of that will perform the actual logging + An instance of the to perform the Application Insights-specific logging (e.g.: Page View) The Logging type - + + + + - + - + - + - The - - class supplies the currently supported, predefined, Log Messages. - There is an additional - - method for any currently not implemented log message - - The underlying instance of - - that will perform the actual logging - - An instance of the - - to perform the Application Insights-specific logging (e.g.: Page View) - + The class supplies the currently supported, predefined, Log Messages. + There is an additional method for any currently not implemented log message + + The underlying instance of that will perform the actual logging + An instance of the to perform the Application Insights-specific logging (e.g.: Page View) The Logging type + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - This class exists to enable testing of the underlying functionality - it acts solely as a wrapper to - + This class exists to enable testing of the underlying functionality - it acts solely as a wrapper to - This class exists to enable testing of the underlying functionality - it acts solely as a wrapper to - + This class exists to enable testing of the underlying functionality - it acts solely as a wrapper to - + - + - The - - class implements the - - interface to add the Cloud Role Name to the Application Insights logging. + The class implements the interface to add the Cloud Role Name to the Application Insights logging. The Role / Application Name to configure Application Insights with The Instrumentation Key to configure Application Insights with - The - - class implements the - - interface to add the Cloud Role Name to the Application Insights logging. + The class implements the interface to add the Cloud Role Name to the Application Insights logging. The Role / Application Name to configure Application Insights with The Instrumentation Key to configure Application Insights with - + - The - - class is a container for any applicable constants to use during logging + The class is a container for any applicable constants to use during logging configuration. @@ -308,9 +243,7 @@ - The - - adds specific log messages which, under the hood, use the LoggerMessage.Define method to specify the Log Format + The adds specific log messages which, under the hood, use the LoggerMessage.Define method to specify the Log Format The type of logger @@ -321,6 +254,14 @@ The name of the API being called The URI being called + + + The LogApiCallStart method logs the call (using the Debug level) for the specified API - including additional information + + The name of the API being called + The URI being called + Additional Information to log + The LogApiCallSuccess method logs the call (using the Debug level) to the specified API @@ -344,6 +285,18 @@ The URI being called The failure message to log + + + The LogDebug method does exactly what its name says + + The message to be logged + + + + The LogInformation method does exactly what its name says + + The message to be logged + The LogException method does exactly what its name says @@ -358,19 +311,11 @@ - The ReturnLoggedFailure will log the Health Check failure and return the - - object + The ReturnLoggedFailure will log the Health Check failure and return the object - The instance of - - from the original call - + The instance of from the original call The name of the API being called - An instance of - - appropriately configured - + An instance of appropriately configured @@ -438,6 +383,11 @@ Defines the ApiCallStart message definition + + + Defines the ApiCallStart message definition with additional information + + Defines the ApiCallSuccess message definition @@ -462,6 +412,16 @@ Defines the ExceptionLogMessage message definition + + + Defines the ExceptionLogMessage message definition + + + + + Defines the ExceptionLogMessage message definition + + @@ -497,16 +457,12 @@ - The - - class contains, as you might expect, extension methods for configuring Serilog / Application Insights. + The class contains, as you might expect, extension methods for configuring Serilog / Application Insights. - The - - method will add Serilog to the logging providers. + The method will add Serilog to the logging providers. @@ -514,16 +470,12 @@ The name (including extension) of the file containing the Serilog Configuration settings. - The original instance of - - for further method chaining. + The original instance of for further method chaining. - The - - class which is used to configure the logging. + The class which is used to configure the logging. @@ -533,9 +485,7 @@ - The - - class used by Serilog WriteTo section of the logging configuration. + The class used by Serilog WriteTo section of the logging configuration. @@ -545,9 +495,7 @@ - The - - class used by Serilog Console section of the logging configuration. + The class used by Serilog Console section of the logging configuration. @@ -557,16 +505,12 @@ - The - - class used to supply the Formatter Options to use. + The class used to supply the Formatter Options to use. - The - - class used by the Serilog Console logger. + The class used by the Serilog Console logger. @@ -586,54 +530,42 @@ - Whether to use a UTC Timestamp or not. The default is. + Whether to use a UTC Timestamp or not. The default is . - The - - used to configure the JSON Writer. + The used to configure the JSON Writer. - The - - class containing the configuration options. + The class containing the configuration options. - Whether to use indented JSON or not. The default is. + Whether to use indented JSON or not. The default is . - The - - class used to configure the standard logging. + The class used to configure the standard logging. - An instance of - - class used to configure the Console logger. + An instance of class used to configure the Console logger. - An instance of - - class used to configure the Application Insights logger. + An instance of class used to configure the Application Insights logger. - The - - class used to configure Application Insights. + The class used to configure Application Insights. @@ -653,9 +585,7 @@ - The - - class used to configure Serilog. + The class used to configure Serilog. @@ -665,16 +595,12 @@ - The - - class used to override the standard logging levels. + The class used to override the standard logging levels. - The - - class used to configure the Serilog logging level overrides. + The class used to configure the Serilog logging level overrides. @@ -684,9 +610,7 @@ - The - - logging level. + The logging level. @@ -696,9 +620,7 @@ - The - - class used to configure Serilog. + The class used to configure Serilog. @@ -708,44 +630,32 @@ - An array of - - configurations. + An array of configurations. - The - - log level to use. + The log level to use. - The - - class that contains the Serilog configuration. + The class that contains the Serilog configuration. - The - - class containing the core configuration. + The class containing the core configuration. - The - - class containing the Logging configuration. + The class containing the Logging configuration. - The - - class that configures the relevant WriteTo Serilog logger. + The class that configures the relevant WriteTo Serilog logger. @@ -755,9 +665,7 @@ - An instance of - - to configure the WriteTo Serilog logger. + An instance of to configure the WriteTo Serilog logger. diff --git a/src/AStar.Dev.Logging.Extensions/AStarEventIdList.cs b/src/AStar.Dev.Logging.Extensions/AStarEventIdList.cs index 7760325..f255d0d 100644 --- a/src/AStar.Dev.Logging.Extensions/AStarEventIdList.cs +++ b/src/AStar.Dev.Logging.Extensions/AStarEventIdList.cs @@ -6,6 +6,8 @@ namespace AStar.Dev.Logging.Extensions; /// internal static class AStarEventIdList { + public static readonly EventId Debug = new (1, "Debug"); + public static readonly EventId Information = new (2, "Information"); public static readonly EventId Error = new (500, "Error"); public static readonly EventId CriticalError = new (666, "Critical Error"); public static readonly EventId PageView = new (1_000, "Page View"); diff --git a/src/AStar.Dev.Logging.Extensions/AStarEventIdsCommon.cs b/src/AStar.Dev.Logging.Extensions/AStarEventIdsCommon.cs index 910ee66..b4f531f 100644 --- a/src/AStar.Dev.Logging.Extensions/AStarEventIdsCommon.cs +++ b/src/AStar.Dev.Logging.Extensions/AStarEventIdsCommon.cs @@ -20,5 +20,15 @@ public static class Common /// Gets the preconfigured for logging a critical error /// public static EventId CriticalEventId => AStarEventIdList.CriticalError; + + /// + /// Gets the preconfigured for logging a critical error + /// + public static EventId DebugEventId => AStarEventIdList.Debug; + + /// + /// Gets the preconfigured for logging a critical error + /// + public static EventId InformationEventId => AStarEventIdList.Information; } } \ No newline at end of file diff --git a/src/AStar.Dev.Logging.Extensions/AStarLoggerCommon.cs b/src/AStar.Dev.Logging.Extensions/AStarLoggerCommon.cs index 8a55773..1eaeffb 100644 --- a/src/AStar.Dev.Logging.Extensions/AStarLoggerCommon.cs +++ b/src/AStar.Dev.Logging.Extensions/AStarLoggerCommon.cs @@ -12,6 +12,14 @@ namespace AStar.Dev.Logging.Extensions; /// The Logging type public partial class AStarLogger(ILogger logger, IAStarTelemetryClient telemetryClient) : ILoggerAstar { + /// + public void LogDebug(string message) + => LoggerMessageDefinitionsCommon.Debug(logger, message, null); + + /// + public void LogInformation(string message) + => LoggerMessageDefinitionsCommon.Information(logger, message, null); + /// public void LogException(Exception exception) => LoggerMessageDefinitionsCommon.ExceptionOccurred(logger, exception.GetBaseException().Message, exception); diff --git a/src/AStar.Dev.Logging.Extensions/ILoggerAstarCommon.cs b/src/AStar.Dev.Logging.Extensions/ILoggerAstarCommon.cs index ac1e566..38e193a 100644 --- a/src/AStar.Dev.Logging.Extensions/ILoggerAstarCommon.cs +++ b/src/AStar.Dev.Logging.Extensions/ILoggerAstarCommon.cs @@ -9,6 +9,18 @@ namespace AStar.Dev.Logging.Extensions; /// The type of logger public partial interface ILoggerAstar : ILogger { + /// + /// The LogDebug method does exactly what its name says + /// + /// The message to be logged + void LogDebug(string message); + + /// + /// The LogInformation method does exactly what its name says + /// + /// The message to be logged + void LogInformation(string message); + /// /// The LogException method does exactly what its name says /// diff --git a/src/AStar.Dev.Logging.Extensions/LoggerMessageDefinitionsCommon.cs b/src/AStar.Dev.Logging.Extensions/LoggerMessageDefinitionsCommon.cs index 1d73974..066f27a 100644 --- a/src/AStar.Dev.Logging.Extensions/LoggerMessageDefinitionsCommon.cs +++ b/src/AStar.Dev.Logging.Extensions/LoggerMessageDefinitionsCommon.cs @@ -9,7 +9,7 @@ public static class LoggerMessageDefinitionsCommon /// public static Action CriticalFailure => LoggerMessage.Define( LogLevel.Critical, - AStarEventIds.Common.ExceptionId, + AStarEventIds.Common.CriticalEventId, "Critical failure: {ErrorMessage}"); /// @@ -19,4 +19,20 @@ public static class LoggerMessageDefinitionsCommon LogLevel.Error, AStarEventIds.Common.ExceptionId, "Error: {ErrorMessage}"); + + /// + /// Defines the ExceptionLogMessage message definition + /// + public static Action Debug => LoggerMessage.Define( + LogLevel.Error, + AStarEventIds.Common.DebugEventId, + "Error: {ErrorMessage}"); + + /// + /// Defines the ExceptionLogMessage message definition + /// + public static Action Information => LoggerMessage.Define( + LogLevel.Error, + AStarEventIds.Common.InformationEventId, + "Error: {ErrorMessage}"); } \ No newline at end of file diff --git a/tests/AStar.Dev.Logging.Extensions.Tests.Unit/AStarEventIdsCommonShould.cs b/tests/AStar.Dev.Logging.Extensions.Tests.Unit/AStarEventIdsCommonShould.cs index e42578f..bfdc345 100644 --- a/tests/AStar.Dev.Logging.Extensions.Tests.Unit/AStarEventIdsCommonShould.cs +++ b/tests/AStar.Dev.Logging.Extensions.Tests.Unit/AStarEventIdsCommonShould.cs @@ -5,6 +5,22 @@ namespace AStar.Dev.Logging.Extensions; [TestSubject(typeof(AStarEventIds.Common))] public class AStarEventIdsCommonShould { + [Fact] + public void ContainTheExpectedDebugEventId() + => AStarEventIds.Common.DebugEventId.Id.ShouldBe(1); + + [Fact] + public void ContainTheExpectedDebugName() + => AStarEventIds.Common.DebugEventId.Name.ShouldBe("Debug"); + + [Fact] + public void ContainTheExpectedInformationIdEventId() + => AStarEventIds.Common.InformationEventId.Id.ShouldBe(2); + + [Fact] + public void ContainTheExpectedInformationIdName() + => AStarEventIds.Common.InformationEventId.Name.ShouldBe("Information"); + [Fact] public void ContainTheExpectedExceptionIdEventId() => AStarEventIds.Common.ExceptionId.Id.ShouldBe(500); diff --git a/tests/AStar.Dev.Logging.Extensions.Tests.Unit/LoggerMessageDefinitionsCommonShould.cs b/tests/AStar.Dev.Logging.Extensions.Tests.Unit/LoggerMessageDefinitionsCommonShould.cs index 4ebef28..2015c8a 100644 --- a/tests/AStar.Dev.Logging.Extensions.Tests.Unit/LoggerMessageDefinitionsCommonShould.cs +++ b/tests/AStar.Dev.Logging.Extensions.Tests.Unit/LoggerMessageDefinitionsCommonShould.cs @@ -5,6 +5,24 @@ namespace AStar.Dev.Logging.Extensions; [TestSubject(typeof(LoggerMessageDefinitionsCommon))] public class LoggerMessageDefinitionsCommonShould { + [Fact] + public void DefineTheDebugeMessageAsExpected() + { + var criticalFailure = LoggerMessageDefinitionsCommon.Debug; + + criticalFailure.Method.ToString().ShouldBe("Void b__1(Microsoft.Extensions.Logging.ILogger, System.String, System.Exception)"); + criticalFailure.Target?.ToString().ShouldBe("Microsoft.Extensions.Logging.LoggerMessage+<>c__DisplayClass10_0`1[System.String]"); + } + + [Fact] + public void DefineTheInformationMessageAsExpected() + { + var criticalFailure = LoggerMessageDefinitionsCommon.Information; + + criticalFailure.Method.ToString().ShouldBe("Void b__1(Microsoft.Extensions.Logging.ILogger, System.String, System.Exception)"); + criticalFailure.Target?.ToString().ShouldBe("Microsoft.Extensions.Logging.LoggerMessage+<>c__DisplayClass10_0`1[System.String]"); + } + [Fact] public void DefineTheCriticalFailureMessageAsExpected() {