Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space handling in kwargs output #33

Closed
Arkoniak opened this issue May 4, 2022 · 2 comments
Closed

Space handling in kwargs output #33

Arkoniak opened this issue May 4, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Arkoniak
Copy link
Collaborator

Arkoniak commented May 4, 2022

As it was mentioned in #19 (comment) by default logger does not print space between message and keyword arguments:

julia> with_logger(MiniLogger()) do
       @info "hello" x=4 y=2
       end
[2022-04-29 10:55:19] Info: hellox = 4, y = 2

Relevant piece of code is: https://github.com/JuliaLogging/MiniLoggers.jl/blob/master/src/minilogger.jl#L242-L253

Proper behavior should be:

julia> with_logger(MiniLogger()) do
       @info "hello" x=4 y=2
       end
[2022-04-29 10:55:19] Info: hello x = 4, y = 2

Additional test cases:
There should be no extra space when there are no keywords present:

julia> with_logger(MiniLogger()) do
       @info "hello"
       end
[2022-04-29 10:55:19] Info: hello

And there should be no extra space when there is no text message:

julia> with_logger(MiniLogger()) do
       @info x=4 y=2
       end
[2022-04-29 10:55:19] Info: x = 4, y = 2
@Arkoniak Arkoniak added the bug Something isn't working label May 4, 2022
Arkoniak pushed a commit to Arkoniak/MiniLoggers.jl that referenced this issue May 4, 2022
Arkoniak pushed a commit to Arkoniak/MiniLoggers.jl that referenced this issue May 4, 2022
@Arkoniak
Copy link
Collaborator Author

Arkoniak commented May 4, 2022

Unfortunately it is impossible to generate last test case, due to the way, how Julia prepares message. It can be seen in default logger too

julia> @info x = 3 y = 1
┌ Info: 3
└   y = 1

First argument always stripped to it's value and considered as message itself. Only way to overcome it, that I can find now, is to add empty string at the beginning of the log string

julia> @info "" x = 3 y = 1
┌ Info:
│   x = 3
└   y = 1

or the same in MiniLoggers.jl

julia> with_logger(MiniLogger()) do
       @info "" x=4 y=2
       end
[2022-04-29 10:55:19] Info: x = 4, y = 2

Arkoniak added a commit that referenced this issue May 4, 2022
@Arkoniak Arkoniak closed this as completed May 4, 2022
@cossio
Copy link

cossio commented May 4, 2022

Thanks for handling this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants