Integration of sentry client into zap.Logger is pretty simple:
funcmodifyToSentryLogger(log*zap.Logger, DSNstring) *zap.Logger {
cfg:= zapsentry.Configuration{
Level: zapcore.ErrorLevel, //when to send message to sentryTags: map[string]string{
"component": "system",
},
}
core, err:=zapsentry.NewCore(cfg, zapsentry.NewSentryClientFromDSN(DSN))
//in case of err it will return noop core. so we can safely attach itiferr!=nil {
log.Warn("failed to init zap", zap.Error(err))
}
returnzapsentry.AttachCoreToLogger(core, log)
}