From 885932afe1e9a2d6cc56145b6ae4885edd024d88 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 12 Nov 2023 18:35:46 -0500 Subject: [PATCH] don't try to log if log.init wasn't called --- scada-common/log.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scada-common/log.lua b/scada-common/log.lua index 8a42e45..f876eaa 100644 --- a/scada-common/log.lua +++ b/scada-common/log.lua @@ -13,6 +13,7 @@ local MODE = { APPEND = 0, NEW = 1 } log.MODE = MODE local logger = { + not_ready = true, path = "/log.txt", mode = MODE.APPEND, debug = false, @@ -32,6 +33,8 @@ local free_space = fs.getFreeSpace -- private log write function ---@param msg string local function _log(msg) + if logger.not_ready then return end + local out_of_space = false local time_stamp = os.date("[%c] ") local stamped = time_stamp .. util.strval(msg) @@ -94,6 +97,8 @@ function log.init(path, write_mode, include_debug, dmesg_redirect) else logger.dmesg_out = term.current() end + + logger.not_ready = false end -- close the log file handle