Fixed treefarm logging bugs
parent
7ee0437cda
commit
b263da5abf
|
@ -13,6 +13,7 @@ local Logger = {
|
||||||
level_colors = {
|
level_colors = {
|
||||||
colors.red, colors.orange, colors.yellow, colors.blue, colors.white},
|
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
|
filename = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ function Logger:new(o)
|
||||||
|
|
||||||
-- Open file handler
|
-- Open file handler
|
||||||
if o.filename then
|
if o.filename then
|
||||||
o._file = open(filename, "a")
|
o._file = fs.open(o.filename, "a")
|
||||||
end
|
end
|
||||||
|
|
||||||
return o
|
return o
|
||||||
|
@ -54,7 +55,7 @@ function Logger:log(level, message)
|
||||||
|
|
||||||
-- Log to screen
|
-- Log to screen
|
||||||
local cur_color = term.getTextColor()
|
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.write("[" .. self.prefixes[level + 1] .. "] ")
|
||||||
term.setTextColor(cur_color)
|
term.setTextColor(cur_color)
|
||||||
print(message)
|
print(message)
|
||||||
|
|
Loading…
Reference in New Issue