From da38aa7b837902e6f64384ab9867cc43a40d978e Mon Sep 17 00:00:00 2001 From: atef Date: Fri, 30 Jun 2023 10:27:14 +0200 Subject: [PATCH] rename the log to loginfo and create log debug --- csharp/App/SaliMax/src/Ess/Controller.cs | 2 +- csharp/App/SaliMax/src/Logger.cs | 11 +++++++++-- csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/csharp/App/SaliMax/src/Ess/Controller.cs b/csharp/App/SaliMax/src/Ess/Controller.cs index 64fe03b05..7d6601450 100644 --- a/csharp/App/SaliMax/src/Ess/Controller.cs +++ b/csharp/App/SaliMax/src/Ess/Controller.cs @@ -187,7 +187,7 @@ public static class Controller if (statusRecord.Battery.Eoc) { - "Batteries have reached EOC".Log(); + "Batteries have reached EOC".LogInfo(); config.LastEoc = UnixTime.Now; return false; } diff --git a/csharp/App/SaliMax/src/Logger.cs b/csharp/App/SaliMax/src/Logger.cs index 56414bf66..f89ecb653 100644 --- a/csharp/App/SaliMax/src/Logger.cs +++ b/csharp/App/SaliMax/src/Logger.cs @@ -10,11 +10,18 @@ public static class Logger private const Int32 MaxLogFileCount = 1000; // TODO: move to settings private const String LogFilePath = "LogDirectory/log.txt"; // TODO: move to settings + // ReSharper disable once InconsistentNaming private static readonly ILogger _logger = new CustomLogger(LogFilePath, MaxFileSizeBytes, MaxLogFileCount); - public static T Log(this T t) where T : notnull + public static T LogInfo(this T t) where T : notnull { - // _logger.LogInformation(t.ToString()); // TODO: check warning + _logger.LogInformation(t.ToString()); // TODO: check warning + return t; + } + + public static T LogDebug(this T t) where T : notnull + { + _logger.LogDebug(t.ToString()); // TODO: check warning return t; } } \ No newline at end of file diff --git a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs index e58e5ac26..31afb815c 100644 --- a/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs +++ b/csharp/App/SaliMax/src/SaliMaxRelays/RelaysDevice.cs @@ -18,7 +18,7 @@ public class RelaysDevice } catch (Exception e) { - $"Failed to read from {nameof(RelaysDevice)}\n{e}".Log(); + $"Failed to read from {nameof(RelaysDevice)}\n{e}".LogInfo(); // TODO: log return null; @@ -33,7 +33,7 @@ public class RelaysDevice } catch (Exception e) { - $"Failed to write to {nameof(RelaysDevice)}\n{e}".Log(); + $"Failed to write to {nameof(RelaysDevice)}\n{e}".LogInfo(); } } }