Add console flag for logging initialization
This commit is contained in:
parent
037bdbebcc
commit
f0b69c4dc8
1 changed files with 7 additions and 15 deletions
|
@ -4,26 +4,18 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var levelsMapping = map[zerolog.Level]sentry.Level{
|
||||
zerolog.DebugLevel: sentry.LevelDebug,
|
||||
zerolog.InfoLevel: sentry.LevelInfo,
|
||||
zerolog.WarnLevel: sentry.LevelWarning,
|
||||
zerolog.ErrorLevel: sentry.LevelError,
|
||||
zerolog.FatalLevel: sentry.LevelFatal,
|
||||
zerolog.PanicLevel: sentry.LevelFatal,
|
||||
}
|
||||
|
||||
// Initialize configures ZeroLog with defaults.
|
||||
func Initialize() {
|
||||
func Initialize(console bool) {
|
||||
if console {
|
||||
cw := zerolog.NewConsoleWriter()
|
||||
cw.Out = os.Stderr
|
||||
cw.TimeFormat = "15:04:05"
|
||||
log.Logger = zerolog.New(cw).With().Timestamp().Logger()
|
||||
}
|
||||
|
||||
zerolog.DurationFieldUnit = time.Millisecond
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue