Skip to content

Commit e9208ad

Browse files
author
Andrey Oskin
committed
space handling (#33)
1 parent f11a932 commit e9208ad

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.jl.mem
44
Manifest.toml
55
/docs/build/
6+
extras/

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MiniLoggers"
22
uuid = "93f3dd0f-005d-4452-894a-a31841fa4078"
33
authors = ["Andrey Oskin and contributors"]
4-
version = "0.4.2"
4+
version = "0.4.3"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

extras/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

extras/Project.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/minilogger.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ function handle_message(logger::MiniLogger, level, message, _module, group, id,
238238
printwcolor(iob, tsnow(logger.dtformat), c)
239239
elseif val == "message"
240240
showmessage(iob, message, logger, logger.mode)
241+
if length(kwargs) > 0 && !isempty(message)
242+
print(iob, " ")
243+
end
241244

242245
iscomma = false
243246
for (key, val) in kwargs

test/test02_loggerformat.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ conts(s, sub) = match(Regex(sub), s) !== nothing
2626
end
2727
end
2828

29+
@testset "contracting kwarg values" begin
30+
io = IOBuffer()
31+
logger = MiniLogger(io = io, format = "{message}")
32+
with_logger(logger) do
33+
@info "hello" x = 4 y = 2
34+
s = String(take!(io))
35+
@test s == "hello x = 4, y = 2\n"
36+
37+
@info "hello"
38+
s = String(take!(io))
39+
@test s == "hello\n"
40+
41+
# Due to the way message is generated, it is impossible to make it more natural
42+
@info x = 4 y = 2
43+
s = String(take!(io))
44+
@test s == "4 y = 2\n"
45+
46+
@info "hello" x = 4 " and " y = 2
47+
s = String(take!(io))
48+
@test s == "hello x = 4 and y = 2\n"
49+
end
50+
end
51+
2952
@testset "squashing" begin
3053
io = IOBuffer()
3154
logger = MiniLogger(io = io, format = "{message}")
@@ -95,7 +118,7 @@ end
95118
y = "asd"
96119

97120
with_logger(logger) do
98-
@info "values: " x y
121+
@info "values:" x y
99122

100123
s = String(take!(io))
101124
@test s == "values: x = 1, y = asd\n"
@@ -119,7 +142,7 @@ end
119142
try
120143
error("ERROR")
121144
catch err
122-
@error "foo " exception = (err, catch_backtrace())
145+
@error "foo" exception = (err, catch_backtrace())
123146
end
124147

125148
s = String(take!(io))

0 commit comments

Comments
 (0)