Fixed treefarm logging bugs
parent
7ee0437cda
commit
b263da5abf
|
@ -13,6 +13,7 @@ local Logger = {
|
|||
level_colors = {
|
||||
colors.red, colors.orange, colors.yellow, colors.blue, colors.white},
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue