forked from TrueCloudLab/frostfs-node
[#1673] logger: Add sampling for journald logger
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
ff4e9b6ae1
commit
7893d763d1
1 changed files with 13 additions and 1 deletions
|
@ -2,6 +2,7 @@ package logger
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/zapjournald"
|
||||
"github.com/ssgreg/journald"
|
||||
|
@ -166,7 +167,18 @@ func newJournaldLogger(prm *Prm) (*Logger, error) {
|
|||
zapjournald.SyslogPid(),
|
||||
})
|
||||
|
||||
lZap := zap.New(coreWithContext, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)), zap.AddCallerSkip(1))
|
||||
var samplerOpts []zapcore.SamplerOption
|
||||
if c.Sampling.Hook != nil {
|
||||
samplerOpts = append(samplerOpts, zapcore.SamplerHook(c.Sampling.Hook))
|
||||
}
|
||||
samplingCore := zapcore.NewSamplerWithOptions(
|
||||
coreWithContext,
|
||||
time.Second,
|
||||
c.Sampling.Initial,
|
||||
c.Sampling.Thereafter,
|
||||
samplerOpts...,
|
||||
)
|
||||
lZap := zap.New(samplingCore, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)), zap.AddCallerSkip(1))
|
||||
|
||||
l := &Logger{z: lZap, lvl: lvl}
|
||||
prm._log = l
|
||||
|
|
Loading…
Add table
Reference in a new issue