@@ -5,7 +5,7 @@ namespace AStar.Dev.Logging.Extensions;
55/// <summary>
66/// Provides static methods for logging specific HTTP-related events using strongly-typed logging templates.
77/// </summary>
8- public static partial class LogMessageTemplate
8+ public static partial class LogMessage
99{
1010 /// <summary>
1111 /// Logs an informational message indicating that a specific page has been viewed.
@@ -15,6 +15,64 @@ public static partial class LogMessageTemplate
1515 [ LoggerMessage ( EventId = 200 , Level = LogLevel . Information , Message = "Page `{PageName}` viewed." ) ]
1616 public static partial void PageView ( ILogger logger , string pageName ) ;
1717
18+ /// <summary>
19+ /// Logs an informational message indicating that a specific page has been viewed.
20+ /// </summary>
21+ /// <param name="logger">The logger to be used for logging the event.</param>
22+ /// <param name="pageName">The name of the page that was viewed.</param>
23+ [ LoggerMessage ( EventId = 200 , Level = LogLevel . Information , Message = "Page `{PageName}` viewed." ) ]
24+ public static partial void Trace ( ILogger logger , string pageName ) ;
25+
26+ /// <summary>
27+ /// Logs a debug message for the specified location.
28+ /// </summary>
29+ /// <param name="logger">The logger to be used for logging the event.</param>
30+ /// <param name="location">The location of the event.</param>
31+ /// <param name="debugMessage">The debug message to log.</param>
32+ [ LoggerMessage ( EventId = 200 , Level = LogLevel . Debug , Message = "{Location} has raised: `{DebugMessage}`." ) ]
33+ public static partial void Debug ( ILogger logger , string location , string debugMessage ) ;
34+
35+ /// <summary>
36+ /// Logs an informational message for the specified location.
37+ /// </summary>
38+ /// <param name="logger">The logger to be used for logging the event.</param>
39+ /// <param name="location">The location of the event.</param>
40+ /// <param name="informationMessage">The information message to log.</param>
41+ [ LoggerMessage ( EventId = 200 , Level = LogLevel . Information , Message = "{Location} has raised: `{InformationMessage}`." ) ]
42+ public static partial void Information ( ILogger logger , string location , string informationMessage ) ;
43+
44+ /// <summary>
45+ /// Logs an informational message with details about a specific API call.
46+ /// </summary>
47+ /// <param name="logger">The logger to be used for logging the event.</param>
48+ /// <param name="location">The location where the event occurred.</param>
49+ /// <param name="httpRequest">A summary of the request.</param>
50+ /// <param name="httpMethod">The HTTP Method (GET / POST etc.)</param>
51+ /// <param name="apiEndpoint">The API Endpoint called.</param>
52+ /// <param name="apiName">The name of the API.</param>
53+ [ LoggerMessage ( EventId = 200 , Level = LogLevel . Information , Message = "{Location} - request: {HttpRequest}, Method: {HttpMethod}, apiEndpoint: {ApiEndpoint}, apiName: {ApiName}." ) ]
54+ public static partial void Information ( ILogger logger , string location , string httpRequest , string httpMethod , string apiEndpoint , string apiName ) ;
55+
56+ /// <summary>
57+ /// Logs a warning message for the specified location.
58+ /// </summary>
59+ /// <param name="logger">The logger to be used for logging the event.</param>
60+ /// <param name="location">The location of the event.</param>
61+ /// <param name="warningMessage">The warning message to log.</param>
62+ [ LoggerMessage ( EventId = 400 , Level = LogLevel . Warning , Message = "{Location} has raised: `{WarningMessage}`." ) ]
63+ public static partial void Warning ( ILogger logger , string location , string warningMessage ) ;
64+
65+ /// <summary>
66+ /// Logs a critical exception event, providing detailed information about the exception type, message, and stack trace.
67+ /// </summary>
68+ /// <param name="logger">The logger used to log the event.</param>
69+ /// <param name="location">The location of the event.</param>
70+ /// <param name="exceptionType">The type of the exception being logged.</param>
71+ /// <param name="exceptionMessage">The message associated with the exception.</param>
72+ /// <param name="exceptionStack">The stack trace of the exception.</param>
73+ [ LoggerMessage ( EventId = 500 , Level = LogLevel . Error , Message = "{Location} encountered {exceptionType} with `{exceptionMessage}`\n ExceptionStack: {exceptionStack}" ) ]
74+ public static partial void LogException ( ILogger logger , string location , string exceptionType , string exceptionMessage , string exceptionStack ) ;
75+
1876 /// <summary>
1977 /// Logs a warning message for a Bad Request (400) event, including the requested path.
2078 /// </summary>
0 commit comments