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

The string type does not automatically add spaces. #889

Closed
FH0 opened this issue Dec 15, 2020 · 1 comment
Closed

The string type does not automatically add spaces. #889

FH0 opened this issue Dec 15, 2020 · 1 comment

Comments

@FH0
Copy link

FH0 commented Dec 15, 2020

a := "a"
zap.S().Debug(a, a)
fmt.Println(a, a)

zap will print "aa"
fmt will print "a a"

@johnaoss
Copy link

@FH0 The SugaredLogger.Debug documentation states that Debug uses fmt.Sprint internally for creating strings.

The behaviour of fmt.Sprint is:

Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.

Whereas you show fmt.Println which says:

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

@FH0 FH0 closed this as completed Dec 17, 2020
abhinav pushed a commit that referenced this issue Apr 12, 2022
The existing `SugaredLogger.${Level}(..)` methods use `fmt.Print`-style
formatting.  Add `${Level}ln` variants for `Println`-stye formatting.

Refs #889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants