grafana-backuper/internal/logger/logger.go
Tom Neuber be915c8d38
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/deploy Pipeline was successful
fix: add linter exceptions for current code style
2025-04-18 15:06:11 +02:00

29 lines
816 B
Go

package logger
import (
"fmt"
"io"
"path/filepath"
"time"
"github.com/rs/zerolog"
)
func CliLoggerLayout(out io.Writer) zerolog.Logger {
//nolint:reassign // overwriting the default caller layout with the desired layout
zerolog.CallerMarshalFunc = func(_ uintptr, file string, line int) string {
return fmt.Sprintf("%s:%d", filepath.Base(file), line)
}
if zerolog.GlobalLevel() == zerolog.DebugLevel {
debugOutput := zerolog.ConsoleWriter{Out: out, TimeFormat: time.RFC3339}
return zerolog.New(debugOutput).With().Timestamp().Caller().Logger()
}
output := zerolog.ConsoleWriter{Out: out, PartsExclude: []string{"time", "level"}}
return zerolog.New(output).With().Logger()
}
func JSONLoggerLayout(out io.Writer) zerolog.Logger {
return zerolog.New(out).With().Timestamp().Caller().Logger()
}