Skip to content

Commit b4208fe

Browse files
authored
Merge pull request #34 from Arkoniak/33-spacekwargs
space handling (#33)
2 parents f11a932 + d824206 commit b4208fe

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-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: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ 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 "" x = 4 y = 2
47+
s = String(take!(io))
48+
@test s == "x = 4, y = 2\n"
49+
50+
@info "hello" x = 4 " and " y = 2
51+
s = String(take!(io))
52+
@test s == "hello x = 4 and y = 2\n"
53+
end
54+
end
55+
2956
@testset "squashing" begin
3057
io = IOBuffer()
3158
logger = MiniLogger(io = io, format = "{message}")
@@ -95,7 +122,7 @@ end
95122
y = "asd"
96123

97124
with_logger(logger) do
98-
@info "values: " x y
125+
@info "values:" x y
99126

100127
s = String(take!(io))
101128
@test s == "values: x = 1, y = asd\n"
@@ -119,7 +146,7 @@ end
119146
try
120147
error("ERROR")
121148
catch err
122-
@error "foo " exception = (err, catch_backtrace())
149+
@error "foo" exception = (err, catch_backtrace())
123150
end
124151

125152
s = String(take!(io))

0 commit comments

Comments
 (0)