diff --git a/go.mod b/go.mod index 2bd5ddef9..3466d80a4 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/bwmarrin/discordgo v0.29.0 github.com/caarlos0/env/v11 v11.3.1 github.com/chzyer/readline v1.5.1 + github.com/ergochat/irc-go v0.5.0 github.com/gdamore/tcell/v2 v2.13.8 github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 @@ -19,6 +20,7 @@ require ( github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.1 github.com/openai/openai-go/v3 v3.22.0 github.com/rivo/tview v0.42.0 + github.com/rs/zerolog v1.34.0 github.com/slack-go/slack v0.17.3 github.com/spf13/cobra v1.10.2 github.com/stretchr/testify v1.11.1 @@ -37,7 +39,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/elliotchance/orderedmap/v3 v3.1.0 // indirect - github.com/ergochat/irc-go v0.5.0 // indirect github.com/gdamore/encoding v1.0.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/lucasb-eyer/go-colorful v1.3.0 // indirect @@ -48,7 +49,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rs/zerolog v1.34.0 // indirect github.com/segmentio/asm v1.1.3 // indirect github.com/segmentio/encoding v0.5.3 // indirect github.com/spf13/pflag v1.0.10 // indirect diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 6fbfdba32..c292e68ee 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -43,30 +43,7 @@ func init() { consoleWriter := zerolog.ConsoleWriter{ Out: os.Stdout, - TimeFormat: "15:04:05", - NoColor: false, - } - - consoleWriter.FormatLevel = func(i any) string { - level, ok := i.(string) - if !ok { - return fmt.Sprintf("| %-5s |", i) - } - - switch strings.ToUpper(level) { - case "DEBUG": - return "| \x1b[36mDBG\x1b[0m |" - case "INFO": - return "| \x1b[32mINF\x1b[0m |" - case "WARN": - return "| \x1b[33mWRN\x1b[0m |" - case "ERROR": - return "| \x1b[31mERR\x1b[0m |" - case "FATAL": - return "| \x1b[35mFTL\x1b[0m |" - default: - return fmt.Sprintf("| %-5s |", level) - } + TimeFormat: "15:04:05", // TODO: make it configurable??? } logger = zerolog.New(consoleWriter).With().Timestamp().Logger() @@ -164,9 +141,9 @@ func logMessage(level LogLevel, component string, message string, fields map[str // Build combined field with component and caller if component != "" { - event.Str("caller", fmt.Sprintf("%-6s | %s:%d (%s)", component, callerFile, callerLine, callerFunc)) + event.Str("caller", fmt.Sprintf("%-6s %s:%d (%s)", component, callerFile, callerLine, callerFunc)) } else { - event.Str("caller", fmt.Sprintf(" | %s:%d (%s)", callerFile, callerLine, callerFunc)) + event.Str("caller", fmt.Sprintf(" %s:%d (%s)", callerFile, callerLine, callerFunc)) } for k, v := range fields { @@ -380,22 +357,3 @@ func (b *Logger) WithLevels(levels map[int]LogLevel) *Logger { func NewLogger(component string) *Logger { return &Logger{component: component} } - -// for debugging logger only -// -//nolint:unused -func debugCallerInfo() { - for i := 2; i < 15; i++ { - pc, file, line, ok := runtime.Caller(i) - if !ok { - continue - } - - fn := runtime.FuncForPC(pc) - if fn == nil { - continue - } - - fmt.Println(file, line) - } -}