-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: StdlibAdaptor timestamp value is weird in logfmt format #434
Comments
That's the way the stdlib timestamp comes to us. As far as I can tell, changing it would involve parsing and reformatting as time.RFC3339[Nano]. I'm not sure that juice is worth the squeeze. Do you think? |
The quotes are required by logfmt because of the space in the value. The date and time formatting done by the stdlib log package is hard coded and doesn't even use There is a workaround readily available, which is to turn off time recording on the stdlib log package and let the Go kit logger do that so that it is always consistent. See below. package main
import (
"log"
"os"
kitlog "github.com/go-kit/kit/log"
)
func main() {
logger := kitlog.NewLogfmtLogger(os.Stdout)
logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC)
slog := kitlog.NewStdlibAdapter(logger)
log.SetFlags(log.Lshortfile)
log.SetOutput(slog)
log.Println("hello world")
} Output:
|
@peterbourgon Ha, I've never heard that phrase before. :D I was hoping it could be made uniform. It causes stutter in the terminal log output. @ChrisHines Makes sense; forgot about the space. Good idea about the workaround. I can use that. |
Good point. I'm open to this. |
I reckon this is finished now that #438 is |
Yes, it is finished. But to clarify, #438 was closed without merging. |
It's quoted and doesn't match the RFC3339 format of DefaultTimestamp/UTC:
The text was updated successfully, but these errors were encountered: