namespace Core.Blueprint.Logging
{
///
/// Provides logging functionalities using Serilog.
///
public class LoggerProvider : ILoggerProvider
{
private readonly Serilog.ILogger logger;
///
/// Initializes a new instance of the class.
///
/// The Serilog logger instance.
public LoggerProvider(Serilog.ILogger logger)
{
this.logger = logger;
}
///
/// Logs an informational message for a specific service.
///
/// The name of the service.
/// Additional arguments to include in the log.
public void LogInformation(string service, params object[] args)
{
logger.Information("Starting operation in {service} service", service, args);
}
///
/// Logs a message indicating the start of an operation in a specific service.
///
/// The name of the service.
/// Additional parameters associated with the operation.
public void LogOperationStarted(string service, params object[] args)
{
logger.Information("Starting operation in {Service} service with parameters: {@Args}", service, args);
}
///
/// Logs a message indicating the completion of an operation in a specific service.
///
/// The name of the service.
/// Additional parameters associated with the operation.
public void LogOperationFinished(string service, params object[] args)
{
logger.Information("Finishing operation in {Service} service with parameters: {@Args}", service, args);
}
///
/// Logs a general informational message.
///
/// The message to log.
public void LogInformation(string message)
{
logger.Information(message);
}
///
/// Logs a warning message with additional context.
///
/// The warning message to log.
/// Additional arguments to include in the log.
public void LogWarning(string message, params object[] args)
{
logger.Warning(message, args);
}
///
/// Logs an error that occurred in a specific service.
///
/// The name of the service.
/// Additional details about the error.
public void LogError(string service, params object[] args)
{
logger.Error("An error occurred in `{service}` Exception: {@Args}", service, args);
}
///
/// Logs a critical error with an exception, message, and additional context.
///
/// The exception associated with the critical error.
/// The critical error message.
/// Additional arguments to include in the log.
public void LogCritical(Exception exception, string message, params object[] args)
{
logger.Fatal(exception, message, args);
}
}
}