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

log: document Print and Printf adding newlines more #16564

Closed
joegrasse opened this issue Aug 1, 2016 · 6 comments
Closed

log: document Print and Printf adding newlines more #16564

joegrasse opened this issue Aug 1, 2016 · 6 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@joegrasse
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6.3 linux/386
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="386"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="386"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/usr2/ps/isp/go"
    GORACE=""
    GOROOT="/usr/local/go"
    GOTOOLDIR="/usr/local/go/pkg/tool/linux_386"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"
  3. What did you do?
    https://play.golang.org/p/qF9NrwS_2Y
  4. What did you expect to see?
    2009/11/10 23:00:00 1st Line.
    2009/11/10 23:00:00 2nd Line. I want on 2nd line as well.
    2009/11/10 23:00:00 3rd Line.I want on the 3rd line
  5. What did you see instead?
    2009/11/10 23:00:00 1st Line.
    2009/11/10 23:00:00 2nd Line.
    2009/11/10 23:00:00 I want on 2nd line as well.
    2009/11/10 23:00:00 3rd Line.
    2009/11/10 23:00:00 I want on the 3rd line
@bradfitz
Copy link
Contributor

bradfitz commented Aug 1, 2016

This is a documented feature of the log package: https://golang.org/pkg/log/#Logger.Output

Use the fmt package if you want control over line endings.

@bradfitz bradfitz closed this as completed Aug 1, 2016
@joegrasse
Copy link
Author

I now see that this is documented. However, this seems very counterintuitive based on the fact that the 3 different function exist for the log package.

@bradfitz
Copy link
Contributor

bradfitz commented Aug 1, 2016

True. Maybe it warrants more docs.

@bradfitz bradfitz reopened this Aug 1, 2016
@bradfitz bradfitz added this to the Go1.8Maybe milestone Aug 1, 2016
@bradfitz bradfitz changed the title log: Print, Println, Printf all add newlines log: document Print adding newlines more Aug 1, 2016
@joegrasse joegrasse changed the title log: document Print adding newlines more log: document Print and Printf adding newlines more Aug 1, 2016
@joegrasse
Copy link
Author

Probably too late now, but it would be nicer for Println vs Print to work as expected. When falling back to fmt, you lose a lot of the niceties that log provides, such as SetOutput, SetPrefix, etc.

@bradfitz
Copy link
Contributor

bradfitz commented Aug 1, 2016

Yeah, we won't be changing the behavior.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@gopherbot
Copy link

CL https://golang.org/cl/31578 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants