Skip to content

Commit 45b26a2

Browse files
committed
fix(ConsoleSink): allow non async console logging
The async attribute was being set to true by default using the or construct, making it impossible to pass false as value. Add missing test.
1 parent 68a5fa8 commit 45b26a2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lua/structlog/sinks/console.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ setmetatable(Console, {
1616

1717
function Console:new(async)
1818
local console = {
19-
async = async or true,
19+
async = async,
2020
}
2121

2222
Console.__index = Console

test/unit/sinks/console_spec.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local log = require("structlog")
2+
local Console = log.sinks.Console
3+
4+
local stub = require("luassert.stub")
5+
6+
describe("Console constructor", function()
7+
local handler = {}
8+
stub(handler, "handle")
9+
10+
it("should create an async console logger", function()
11+
local sink = Console(true)
12+
13+
assert.True(sink.async)
14+
end)
15+
16+
it("should create an non-async console logger", function()
17+
local sink = Console(false)
18+
19+
assert.False(sink.async)
20+
end)
21+
end)

0 commit comments

Comments
 (0)