package logger import ( "fmt" "io" "path/filepath" "time" "github.com/rs/zerolog" ) func CliLoggerLayout(out io.Writer) zerolog.Logger { 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() }