diff --git a/csharp/App/SaliMax/src/Logfile.cs b/csharp/App/SaliMax/src/Logfile.cs index d31ebd8c8..b3fe2510e 100644 --- a/csharp/App/SaliMax/src/Logfile.cs +++ b/csharp/App/SaliMax/src/Logfile.cs @@ -37,7 +37,7 @@ public class CustomLogger : ILogger File.AppendAllText(_LogFilePath, logMessage + Environment.NewLine); _CurrentFileSizeBytes += logMessage.Length; - Console.WriteLine(logMessage); + //Console.WriteLine(logMessage); } private void RotateLogFile() diff --git a/csharp/App/SaliMax/src/Logger.cs b/csharp/App/SaliMax/src/Logger.cs index 666cad058..f0544095d 100644 --- a/csharp/App/SaliMax/src/Logger.cs +++ b/csharp/App/SaliMax/src/Logger.cs @@ -6,9 +6,9 @@ public static class Logger { // Specify the maximum log file size in bytes (e.g., 1 MB) - private const Int32 MaxFileSizeBytes = 1024 * 1024; // TODO: move to settings - private const Int32 MaxLogFileCount = 1000; // TODO: move to settings - private const String LogFilePath = "LogDirectory/log.txt"; // TODO: move to settings + private const Int32 MaxFileSizeBytes = 1024 * 21; // TODO: move to settings + private const Int32 MaxLogFileCount = 5000; // TODO: move to settings + private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings // ReSharper disable once InconsistentNaming private static readonly ILogger _logger = new CustomLogger(LogFilePath, MaxFileSizeBytes, MaxLogFileCount); diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index fd63b0882..6c778dc89 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -184,9 +184,9 @@ internal static class Program record.ControlConstants(); record.ControlSystemState(); - $"{record.StateMachine.State}: {record.StateMachine.Message}".LogInfo(); + $"{UnixTime.Now} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine().LogInfo(); - var essControl = record.ControlEss().LogInfo(); + var essControl = record.ControlEss().WriteLine().LogInfo(); record.EssControl = essControl; @@ -341,11 +341,14 @@ internal static class Program if (s3Config is null) return false; - var csv = status.ToCsv(); + var csv = status.ToCsv().LogInfo(); var s3Path = timeStamp + ".csv"; var request = s3Config.CreatePutRequest(s3Path); var response = await request.PutAsync(new StringContent(csv)); + // This is temporary for Wittman + //await File.WriteAllTextAsync("/var/www/html/status.csv", csv.SplitLines().Where(l => !l.Contains("Secret")).JoinLines()); + if (response.StatusCode != 200) { Console.WriteLine("ERROR: PUT");