2023-06-13 10:53:17 +00:00
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
namespace InnovEnergy.App.SaliMax;
|
|
|
|
|
|
|
|
public static class Logger
|
|
|
|
{
|
|
|
|
// Specify the maximum log file size in bytes (e.g., 1 MB)
|
|
|
|
|
2024-06-20 10:02:06 +00:00
|
|
|
//private const Int32 MaxFileSizeBytes = 2024 * 30; // TODO: move to settings
|
2023-09-27 12:36:50 +00:00
|
|
|
private const Int32 MaxLogFileCount = 5000; // TODO: move to settings
|
|
|
|
private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings
|
2023-06-13 10:53:17 +00:00
|
|
|
|
2023-06-30 08:27:14 +00:00
|
|
|
// ReSharper disable once InconsistentNaming
|
2024-06-20 10:02:06 +00:00
|
|
|
private static readonly ILogger _logger = new CustomLogger(LogFilePath, MaxLogFileCount);
|
2023-06-13 10:53:17 +00:00
|
|
|
|
2023-06-30 08:27:14 +00:00
|
|
|
public static T LogInfo<T>(this T t) where T : notnull
|
2023-06-13 10:53:17 +00:00
|
|
|
{
|
2023-06-30 08:27:14 +00:00
|
|
|
_logger.LogInformation(t.ToString()); // TODO: check warning
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T LogDebug<T>(this T t) where T : notnull
|
|
|
|
{
|
|
|
|
_logger.LogDebug(t.ToString()); // TODO: check warning
|
2023-06-13 10:53:17 +00:00
|
|
|
return t;
|
|
|
|
}
|
2023-07-03 12:21:18 +00:00
|
|
|
|
|
|
|
public static T LogError<T>(this T t) where T : notnull
|
|
|
|
{
|
|
|
|
_logger.LogError(t.ToString()); // TODO: check warning
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T LogWarning<T>(this T t) where T : notnull
|
|
|
|
{
|
|
|
|
_logger.LogWarning(t.ToString()); // TODO: check warning
|
|
|
|
return t;
|
|
|
|
}
|
2023-06-13 10:53:17 +00:00
|
|
|
}
|