WIP: Refactor entire project #16

Draft
tom wants to merge 23 commits from make_linters_happy into main
Showing only changes of commit 840008df2d - Show all commits

28
internal/logger/logger.go Normal file
View file

@ -0,0 +1,28 @@
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()
}