mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
26 lines
591 B
Go
26 lines
591 B
Go
package service
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/formancehq/stack/libs/go-libs/logging"
|
|
"github.com/formancehq/stack/libs/go-libs/otlp/otlptraces"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/viper"
|
|
"github.com/uptrace/opentelemetry-go-extra/otellogrus"
|
|
)
|
|
|
|
func GetDefaultLogger(w io.Writer, debug bool) logging.Logger {
|
|
l := logging.DefaultLogger(w, debug)
|
|
|
|
if viper.GetBool(otlptraces.OtelTracesFlag) {
|
|
l.AddHook(otellogrus.NewHook(otellogrus.WithLevels(
|
|
logrus.PanicLevel,
|
|
logrus.FatalLevel,
|
|
logrus.ErrorLevel,
|
|
logrus.WarnLevel,
|
|
)))
|
|
}
|
|
return logging.NewLogrus(l)
|
|
}
|