Fixed treefarm logging bugs

develop
Jef Roosens 2020-12-28 16:50:47 +01:00
parent 7ee0437cda
commit b263da5abf
1 changed files with 4 additions and 3 deletions

View File

@ -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)