https://github.com/themakers/zapsentry
zap logger sentry core
https://github.com/themakers/zapsentry
Last synced: 5 months ago
JSON representation
zap logger sentry core
- Host: GitHub
- URL: https://github.com/themakers/zapsentry
- Owner: themakers
- License: mit
- Fork: true (TheZeroSlave/zapsentry)
- Created: 2021-01-19T13:24:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-19T21:07:09.000Z (over 5 years ago)
- Last Synced: 2024-06-20T11:15:36.248Z (almost 2 years ago)
- Language: Go
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sentry client for zap logger
Integration of sentry client into zap.Logger is pretty simple:
```golang
func modifyToSentryLogger(log *zap.Logger, DSN string) *zap.Logger {
cfg := zapsentry.Configuration{
Level: zapcore.ErrorLevel, //when to send message to sentry
Tags: 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 it
if err != nil {
log.Warn("failed to init zap", zap.Error(err))
}
return zapsentry.AttachCoreToLogger(core, log)
}
```