From 22f1cb04f3f8a2cb8e0dd996773b9b73f33722ee Mon Sep 17 00:00:00 2001 From: Serge SIMON Date: Fri, 15 Jul 2022 14:57:04 +0200 Subject: [PATCH] #46 --- src/sol.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sol.go b/src/sol.go index 7f61a97..e8007b5 100644 --- a/src/sol.go +++ b/src/sol.go @@ -7,6 +7,7 @@ import ( "path/filepath" "strconv" "strings" + "time" "github.com/integrii/flaggy" "github.com/labstack/gommon/color" @@ -32,10 +33,18 @@ func ExitDaemon(s string) { exit <- true } +func LocalLoggoFormatter(entry loggo.Entry) string { + ts := entry.Timestamp.In(time.Local).Format("2006-01-02 15:04:05") + // Just get the basename from the filename + filename := filepath.Base(entry.Filename) + return fmt.Sprintf("%s %s %s %s:%d %s", ts, entry.Level, entry.Module, filename, entry.Line, entry.Message) +} + func init() { // Preinit loggers with default value (will be later overridden per configuration, if needed) logger.SetLogLevel(loggo.INFO) + loggo.ReplaceDefaultWriter(loggo.NewSimpleWriter(os.Stderr, LocalLoggoFormatter)) // Init flag reader flaggy.String(&configurationFileNameFromCommandLine, "c", "config", "Configuration file to use (optional, default is 'sol.json' next to the binary)")