[#1366] logger: Make timestamp prepending optional
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
66e17f4b8e
commit
7b9bfb783f
1 changed files with 9 additions and 0 deletions
|
@ -40,6 +40,9 @@ type Prm struct {
|
|||
|
||||
// do not support runtime rereading
|
||||
dest string
|
||||
|
||||
// PrependTimestamp specifies whether to prepend a timestamp in the log
|
||||
PrependTimestamp bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -120,6 +123,9 @@ func newConsoleLogger(prm *Prm) (*Logger, error) {
|
|||
if prm.SamplingHook != nil {
|
||||
c.Sampling.Hook = prm.SamplingHook
|
||||
}
|
||||
if !prm.PrependTimestamp {
|
||||
c.EncoderConfig.TimeKey = ""
|
||||
}
|
||||
|
||||
lZap, err := c.Build(
|
||||
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
|
||||
|
@ -144,6 +150,9 @@ func newJournaldLogger(prm *Prm) (*Logger, error) {
|
|||
if prm.SamplingHook != nil {
|
||||
c.Sampling.Hook = prm.SamplingHook
|
||||
}
|
||||
if !prm.PrependTimestamp {
|
||||
c.EncoderConfig.TimeKey = ""
|
||||
}
|
||||
|
||||
encoder := zapjournald.NewPartialEncoder(zapcore.NewConsoleEncoder(c.EncoderConfig), zapjournald.SyslogFields)
|
||||
|
||||
|
|
Loading…
Reference in a new issue