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)