2021-08-03 23:26:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-09-19 18:39:43 +00:00
|
|
|
stdlog "log"
|
|
|
|
|
2022-09-16 16:18:44 +00:00
|
|
|
"github.com/rs/zerolog"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"github.com/rs/zerolog/pkgerrors"
|
2021-08-03 23:26:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func configureLogger() {
|
2022-09-16 16:18:44 +00:00
|
|
|
zerolog.ErrorStackFieldName = "stack_trace"
|
|
|
|
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
|
|
|
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
2022-01-17 03:40:02 +00:00
|
|
|
|
2022-09-19 18:39:43 +00:00
|
|
|
stdlog.SetFlags(0)
|
|
|
|
stdlog.SetOutput(log.Logger)
|
|
|
|
|
2022-09-16 16:18:44 +00:00
|
|
|
log.Logger = log.Logger.With().Caller().Stack().Logger()
|
|
|
|
}
|
2021-08-03 23:26:22 +00:00
|
|
|
|
2022-09-16 16:18:44 +00:00
|
|
|
func setLoggingLevel(level string) {
|
|
|
|
switch level {
|
|
|
|
case "ERROR":
|
|
|
|
zerolog.SetGlobalLevel(zerolog.ErrorLevel)
|
|
|
|
case "WARN":
|
|
|
|
zerolog.SetGlobalLevel(zerolog.WarnLevel)
|
|
|
|
case "INFO":
|
|
|
|
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
|
|
|
case "DEBUG":
|
|
|
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
|
|
|
}
|
2021-08-03 23:26:22 +00:00
|
|
|
}
|