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.Println() does not print timestamp #829

Closed
bharatkrishna opened this issue Mar 7, 2017 · 5 comments · Fixed by #1560
Closed

log.Println() does not print timestamp #829

bharatkrishna opened this issue Mar 7, 2017 · 5 comments · Fixed by #1560
Labels
Milestone

Comments

@bharatkrishna
Copy link

I am using log.Println() inside the router callback functions to print debug messages. These get printed to console but they don't have timestamps. How do I enable it log timestamps?

@feute
Copy link

feute commented Mar 8, 2017

gin disables the log flags in debug.go#14.

I don't know the reason behind this, rather than hiding the timestamps when printing debug information when calling debugPrint here.

But you may enable them as so:

log.SetFlags(log.LstdFlags)

Or, including the file and line number:

log.SetFlags(log.LstdFlags | log.Lshortfile)

@bharatkrishna
Copy link
Author

Thanks, it works after I did log.SetFlags(log.LstdFlags). This was what I wanted.

@peragwin
Copy link

I think this should be reopened. If gin wants to use it's own logging format, it should use its own logger via log.New(). Under no circumstances should it be changing global settings in another package whose behavior others might depend on.

@philippgille
Copy link

The last comment is more than a year old, but I just stumbled across the issue as well and I'm of the same opinion as @peragwin.

@bharatkrishna: Do you mind reopening the issue?

Does anyone from the Gin team want to share their thoughts?

@appleboy
Copy link
Member

@appleboy appleboy added the bug label Sep 19, 2018
@appleboy appleboy added this to the 1.4 milestone Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants