From b263da5abf35670f2e5e3a9056b061feb6db1c2a Mon Sep 17 00:00:00 2001 From: ChewingBever Date: Mon, 28 Dec 2020 16:50:47 +0100 Subject: [PATCH] Fixed treefarm logging bugs --- jlib/log.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jlib/log.lua b/jlib/log.lua index c39d0dc..ab69b9d 100644 --- a/jlib/log.lua +++ b/jlib/log.lua @@ -12,7 +12,8 @@ local Logger = { level = 2, level_colors = { colors.red, colors.orange, colors.yellow, colors.blue, colors.white}, - prefixes = { "CRIT", "ERROR", "WARN", "INFO", "DEBUG" }, + prefixes = {"CRIT", "ERROR", "WARN", "INFO", "DEBUG"}, + -- Explicit is better than implicit filename = nil } @@ -37,7 +38,7 @@ function Logger:new(o) -- Open file handler if o.filename then - o._file = open(filename, "a") + o._file = fs.open(o.filename, "a") end return o @@ -54,7 +55,7 @@ function Logger:log(level, message) -- Log to screen local cur_color = term.getTextColor() - term.setTextColor(self.colors[level + 1]) + term.setTextColor(self.level_colors[level + 1]) term.write("[" .. self.prefixes[level + 1] .. "] ") term.setTextColor(cur_color) print(message)