golang logrus
log output format sample
1 | INFO[2021-07-04 15:26:26]main.go:28 have a nice day zs=log |
code sample
show timestamp
the meaning of [0000]
add common prefix
have a little overhead, add filename and line number
- https://github.com/sirupsen/logrus/issues/63#issuecomment-548792922
- https://github.com/sirupsen/logrus#logging-method-name
- https://github.com/sirupsen/logrus/blob/master/example_custom_caller_test.go
1 | package main |
third-party formatter
https://github.com/sirupsen/logrus#formatters
log output format sample
1 | [2021-07-04 15:50:26] INFO log: have a nice day |
code sample
1 | package main |
as previous code show
1 | contextLogger := log.WithField("prefix", "log") |
u can prefix a log key and colon before the msg output