From a4e5835e3490f59d6954d2f659ec8cb0a2c36e2c Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:00:35 +1100 Subject: [PATCH] Logs now show date time rather than x hours ago (#169) --- gaseous-server/Classes/Metadata/Storage.cs | 25 ++++++++++++------- .../wwwroot/pages/settings/logs.html | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/gaseous-server/Classes/Metadata/Storage.cs b/gaseous-server/Classes/Metadata/Storage.cs index 61ebe7c..763cffd 100644 --- a/gaseous-server/Classes/Metadata/Storage.cs +++ b/gaseous-server/Classes/Metadata/Storage.cs @@ -457,18 +457,25 @@ namespace gaseous_server.Classes.Metadata private static void CacheClean() { - if (ObjectCache == null) + try + { + if (ObjectCache == null) + { + ObjectCache = new Dictionary(); + } + Dictionary workCache = ObjectCache; + foreach (KeyValuePair objectCache in workCache) + { + if (objectCache.Value.ExpiryTime < DateTime.UtcNow) + { + ObjectCache.Remove(objectCache.Key); + } + } + } + catch { ObjectCache = new Dictionary(); } - Dictionary workCache = ObjectCache; - foreach (KeyValuePair objectCache in workCache) - { - if (objectCache.Value.ExpiryTime < DateTime.UtcNow) - { - ObjectCache.Remove(objectCache.Key); - } - } } private class MemoryCacheObject diff --git a/gaseous-server/wwwroot/pages/settings/logs.html b/gaseous-server/wwwroot/pages/settings/logs.html index 3e6b25d..1c0c8fd 100644 --- a/gaseous-server/wwwroot/pages/settings/logs.html +++ b/gaseous-server/wwwroot/pages/settings/logs.html @@ -54,7 +54,7 @@ var newRow = [ //result[i].id, - moment(result[i].eventTime).fromNow(), + moment(result[i].eventTime).format("YYYY-MM-DD H:mm:ss"), result[i].eventType, result[i].process, result[i].message