Add project files.
This commit is contained in:
		
							
								
								
									
										89
									
								
								Core.Blueprint.Logging/Provider/LoggerProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								Core.Blueprint.Logging/Provider/LoggerProvider.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | ||||
| namespace Core.Blueprint.Logging | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Provides logging functionalities using Serilog. | ||||
|     /// </summary> | ||||
|     public class LoggerProvider : ILoggerProvider | ||||
|     { | ||||
|         private readonly Serilog.ILogger logger; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Initializes a new instance of the <see cref="LoggerProvider"/> class. | ||||
|         /// </summary> | ||||
|         /// <param name="logger">The Serilog logger instance.</param> | ||||
|         public LoggerProvider(Serilog.ILogger logger) | ||||
|         { | ||||
|             this.logger = logger; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs an informational message for a specific service. | ||||
|         /// </summary> | ||||
|         /// <param name="service">The name of the service.</param> | ||||
|         /// <param name="args">Additional arguments to include in the log.</param> | ||||
|         public void LogInformation(string service, params object[] args) | ||||
|         { | ||||
|             logger.Information("Starting operation in {service} service", service, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs a message indicating the start of an operation in a specific service. | ||||
|         /// </summary> | ||||
|         /// <param name="service">The name of the service.</param> | ||||
|         /// <param name="args">Additional parameters associated with the operation.</param> | ||||
|         public void LogOperationStarted(string service, params object[] args) | ||||
|         { | ||||
|             logger.Information("Starting operation in {Service} service with parameters: {@Args}", service, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs a message indicating the completion of an operation in a specific service. | ||||
|         /// </summary> | ||||
|         /// <param name="service">The name of the service.</param> | ||||
|         /// <param name="args">Additional parameters associated with the operation.</param> | ||||
|         public void LogOperationFinished(string service, params object[] args) | ||||
|         { | ||||
|             logger.Information("Finishing operation in {Service} service with parameters: {@Args}", service, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs a general informational message. | ||||
|         /// </summary> | ||||
|         /// <param name="message">The message to log.</param> | ||||
|         public void LogInformation(string message) | ||||
|         { | ||||
|             logger.Information(message); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs a warning message with additional context. | ||||
|         /// </summary> | ||||
|         /// <param name="message">The warning message to log.</param> | ||||
|         /// <param name="args">Additional arguments to include in the log.</param> | ||||
|         public void LogWarning(string message, params object[] args) | ||||
|         { | ||||
|             logger.Warning(message, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs an error that occurred in a specific service. | ||||
|         /// </summary> | ||||
|         /// <param name="service">The name of the service.</param> | ||||
|         /// <param name="args">Additional details about the error.</param> | ||||
|         public void LogError(string service, params object[] args) | ||||
|         { | ||||
|             logger.Error("An error occurred in `{service}` Exception: {@Args}", service, args); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Logs a critical error with an exception, message, and additional context. | ||||
|         /// </summary> | ||||
|         /// <param name="exception">The exception associated with the critical error.</param> | ||||
|         /// <param name="message">The critical error message.</param> | ||||
|         /// <param name="args">Additional arguments to include in the log.</param> | ||||
|         public void LogCritical(Exception exception, string message, params object[] args) | ||||
|         { | ||||
|             logger.Fatal(exception, message, args); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin