From 968b0a91229d0dd0af20e310b50bdb1c47e730f8 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 23 Mar 2024 00:49:19 -0400 Subject: [PATCH] log environment versions when debug logs are enabled --- coordinator/startup.lua | 3 ++- pocket/startup.lua | 3 ++- reactor-plc/startup.lua | 3 ++- rtu/startup.lua | 3 ++- scada-common/crash.lua | 23 ++++++++++++++++------- supervisor/startup.lua | 3 ++- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 5b3c46b..2f83016 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,7 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.3.0" +local COORDINATOR_VERSION = "v1.3.1" local CHUNK_LOAD_DELAY_S = 30.0 @@ -103,6 +103,7 @@ log.info("========================================") println(">> SCADA Coordinator " .. COORDINATOR_VERSION .. " <<") crash.set_env("coordinator", COORDINATOR_VERSION) +crash.dbg_log_env() ---------------------------------------- -- main application diff --git a/pocket/startup.lua b/pocket/startup.lua index 3bff062..5b7c91f 100644 --- a/pocket/startup.lua +++ b/pocket/startup.lua @@ -18,7 +18,7 @@ local iocontrol = require("pocket.iocontrol") local pocket = require("pocket.pocket") local renderer = require("pocket.renderer") -local POCKET_VERSION = "v0.7.2-alpha" +local POCKET_VERSION = "v0.7.3-alpha" local println = util.println local println_ts = util.println_ts @@ -54,6 +54,7 @@ log.info("BOOTING pocket.startup " .. POCKET_VERSION) log.info("========================================") crash.set_env("pocket", POCKET_VERSION) +crash.dbg_log_env() ---------------------------------------- -- main application diff --git a/reactor-plc/startup.lua b/reactor-plc/startup.lua index 63167c7..da79744 100644 --- a/reactor-plc/startup.lua +++ b/reactor-plc/startup.lua @@ -18,7 +18,7 @@ local plc = require("reactor-plc.plc") local renderer = require("reactor-plc.renderer") local threads = require("reactor-plc.threads") -local R_PLC_VERSION = "v1.7.1" +local R_PLC_VERSION = "v1.7.2" local println = util.println local println_ts = util.println_ts @@ -55,6 +55,7 @@ log.info("========================================") println(">> Reactor PLC " .. R_PLC_VERSION .. " <<") crash.set_env("reactor-plc", R_PLC_VERSION) +crash.dbg_log_env() ---------------------------------------- -- main application diff --git a/rtu/startup.lua b/rtu/startup.lua index d16751f..071ab40 100644 --- a/rtu/startup.lua +++ b/rtu/startup.lua @@ -31,7 +31,7 @@ local sna_rtu = require("rtu.dev.sna_rtu") local sps_rtu = require("rtu.dev.sps_rtu") local turbinev_rtu = require("rtu.dev.turbinev_rtu") -local RTU_VERSION = "v1.9.0" +local RTU_VERSION = "v1.9.1" local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE local RTU_UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE @@ -71,6 +71,7 @@ log.info("========================================") println(">> RTU GATEWAY " .. RTU_VERSION .. " <<") crash.set_env("rtu", RTU_VERSION) +crash.dbg_log_env() ---------------------------------------- -- main application diff --git a/scada-common/crash.lua b/scada-common/crash.lua index 1942a8d..a7e2c93 100644 --- a/scada-common/crash.lua +++ b/scada-common/crash.lua @@ -24,6 +24,21 @@ function crash.set_env(application, version) ver = version end +-- log environment versions +---@param log_msg function log function to use +local function log_versions(log_msg) + log_msg(util.c("RUNTIME: ", _HOST)) + log_msg(util.c("LUA VERSION: ", _VERSION)) + log_msg(util.c("APPLICATION: ", app)) + log_msg(util.c("FIRMWARE VERSION: ", ver)) + log_msg(util.c("COMMS VERSION: ", comms.version)) + if has_graphics then log_msg(util.c("GRAPHICS VERSION: ", core.version)) end + if has_lockbox then log_msg(util.c("LOCKBOX VERSION: ", lockbox.version)) end +end + +-- when running with debug logs, log the useful information that the crash handler knows +function crash.dbg_log_env() log_versions(log.debug) end + -- handle a crash error ---@param error string error message function crash.handler(error) @@ -31,13 +46,7 @@ function crash.handler(error) log.info("=====> FATAL SOFTWARE FAULT <=====") log.fatal(error) log.info("----------------------------------") - log.info(util.c("RUNTIME: ", _HOST)) - log.info(util.c("LUA VERSION: ", _VERSION)) - log.info(util.c("APPLICATION: ", app)) - log.info(util.c("FIRMWARE VERSION: ", ver)) - log.info(util.c("COMMS VERSION: ", comms.version)) - if has_graphics then log.info(util.c("GRAPHICS VERSION: ", core.version)) end - if has_lockbox then log.info(util.c("LOCKBOX VERSION: ", lockbox.version)) end + log_versions(log.info) log.info("----------------------------------") log.info(debug.traceback("--- begin debug trace ---", 1)) log.info("--- end debug trace ---") diff --git a/supervisor/startup.lua b/supervisor/startup.lua index 4eae495..be57a70 100644 --- a/supervisor/startup.lua +++ b/supervisor/startup.lua @@ -21,7 +21,7 @@ local supervisor = require("supervisor.supervisor") local svsessions = require("supervisor.session.svsessions") -local SUPERVISOR_VERSION = "v1.3.0" +local SUPERVISOR_VERSION = "v1.3.1" local println = util.println local println_ts = util.println_ts @@ -86,6 +86,7 @@ log.info("========================================") println(">> SCADA Supervisor " .. SUPERVISOR_VERSION .. " <<") crash.set_env("supervisor", SUPERVISOR_VERSION) +crash.dbg_log_env() ---------------------------------------- -- main application