Skip to content

Commit

Permalink
#46
Browse files Browse the repository at this point in the history
  • Loading branch information
SR-G committed Jul 15, 2022
1 parent 83a3c18 commit 22f1cb0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sol.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"

"github.com/integrii/flaggy"
"github.com/labstack/gommon/color"
Expand All @@ -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)")
Expand Down

0 comments on commit 22f1cb0

Please sign in to comment.