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

proposal: log/v2: set LstdFlags to zero #44574

Closed
wansing opened this issue Feb 24, 2021 · 3 comments
Closed

proposal: log/v2: set LstdFlags to zero #44574

wansing opened this issue Feb 24, 2021 · 3 comments
Labels
FrozenDueToAge Proposal v2 A language change or incompatible library change WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@wansing
Copy link

wansing commented Feb 24, 2021

In Go 1, we have in the log package:

LstdFlags = Ldate | Ltime // initial values for the standard logger

If the standard logger is used with initial values, then date and time is included twice in e.g. systemd logs.

$ journalctl -e -n 1 --no-pager
Feb 24 12:15:02 mymachine myapplication[...]: 2021/02/24 12:15:02 ...

However, adding timestamps to logs should be a task of the execution environment (e.g. systemd or Docker), and not of the application.

So I propose to set LstdFlags = 0 in Go 2, or just omit it.

@gopherbot gopherbot added this to the Proposal milestone Feb 24, 2021
@ianlancetaylor
Copy link
Contributor

Changing this now would break Go 1 compatibility, so we can't do that.

I see that you suggest changing this in Go 2, but there is no likelihood of having Go 2 in general. We could have a log/v2 package some day, but there are no plans for that.

To be honest, the suggested change doesn't make much sense to me. Most programs do not output to systemd. For those programs, including the date and time makes sense. It seems to me that it is programs that output to systemd that should use log.SetFlags to clear those flags.

@ianlancetaylor ianlancetaylor added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. v2 A language change or incompatible library change labels Feb 24, 2021
@ianlancetaylor ianlancetaylor changed the title proposal: set log.LstdFlags to zero proposal: log/v2: set LstdFlags to zero Feb 24, 2021
@wansing
Copy link
Author

wansing commented Mar 1, 2021

Thanks for the feedback. Most of my programs do output to systemd, and I often see myself writing log.SetFlags(0), but that's probably not representative then. Feel free to close this issue.

@ianlancetaylor
Copy link
Contributor

Thanks, closing.

@golang golang locked and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Proposal v2 A language change or incompatible library change WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants