src/ln: change formatter argument to a table with formatter
This commit is contained in:
parent
2440dbc926
commit
3664cbb504
|
@ -59,4 +59,14 @@ describe("ln", function()
|
|||
assert.truthy(string.find(msg, 'foo="bar with spaces"'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("logger options", function()
|
||||
local lgr = ln.Logger:new {
|
||||
formatter = ln.LogfmtFormatter:new()
|
||||
}
|
||||
|
||||
it("sets the formatter to non-nil", function()
|
||||
assert.truthy(lgr.formatter)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -68,13 +68,12 @@ function Logger:log(...)
|
|||
print(message)
|
||||
end
|
||||
|
||||
function Logger:new(formatter)
|
||||
if formatter == nil then
|
||||
function Logger:new(o)
|
||||
if o == nil then
|
||||
o = {
|
||||
formatter = LogfmtFormatter:new()
|
||||
end
|
||||
local o = {
|
||||
formatter = formatter,
|
||||
}
|
||||
end
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
|
|
Loading…
Reference in New Issue