Adapt logfile to save .csv in local machine.
This commit is contained in:
parent
315fab8463
commit
25d3ae9252
|
@ -37,7 +37,7 @@ public class CustomLogger : ILogger
|
||||||
File.AppendAllText(_LogFilePath, logMessage + Environment.NewLine);
|
File.AppendAllText(_LogFilePath, logMessage + Environment.NewLine);
|
||||||
_CurrentFileSizeBytes += logMessage.Length;
|
_CurrentFileSizeBytes += logMessage.Length;
|
||||||
|
|
||||||
Console.WriteLine(logMessage);
|
//Console.WriteLine(logMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RotateLogFile()
|
private void RotateLogFile()
|
||||||
|
|
|
@ -6,9 +6,9 @@ public static class Logger
|
||||||
{
|
{
|
||||||
// Specify the maximum log file size in bytes (e.g., 1 MB)
|
// 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 MaxFileSizeBytes = 1024 * 21; // TODO: move to settings
|
||||||
private const Int32 MaxLogFileCount = 1000; // TODO: move to settings
|
private const Int32 MaxLogFileCount = 5000; // TODO: move to settings
|
||||||
private const String LogFilePath = "LogDirectory/log.txt"; // TODO: move to settings
|
private const String LogFilePath = "LogDirectory/log.csv"; // TODO: move to settings
|
||||||
|
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
private static readonly ILogger _logger = new CustomLogger(LogFilePath, MaxFileSizeBytes, MaxLogFileCount);
|
private static readonly ILogger _logger = new CustomLogger(LogFilePath, MaxFileSizeBytes, MaxLogFileCount);
|
||||||
|
|
|
@ -184,9 +184,9 @@ internal static class Program
|
||||||
record.ControlConstants();
|
record.ControlConstants();
|
||||||
record.ControlSystemState();
|
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;
|
record.EssControl = essControl;
|
||||||
|
|
||||||
|
@ -341,11 +341,14 @@ internal static class Program
|
||||||
if (s3Config is null)
|
if (s3Config is null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var csv = status.ToCsv();
|
var csv = status.ToCsv().LogInfo();
|
||||||
var s3Path = timeStamp + ".csv";
|
var s3Path = timeStamp + ".csv";
|
||||||
var request = s3Config.CreatePutRequest(s3Path);
|
var request = s3Config.CreatePutRequest(s3Path);
|
||||||
var response = await request.PutAsync(new StringContent(csv));
|
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)
|
if (response.StatusCode != 200)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ERROR: PUT");
|
Console.WriteLine("ERROR: PUT");
|
||||||
|
|
Loading…
Reference in New Issue