Skip to content

Commit

Permalink
Merge pull request #109 from nicolasbock/log_format
Browse files Browse the repository at this point in the history
Make log entries look a bit more readable
  • Loading branch information
nicolasbock authored Dec 4, 2023
2 parents c67dc92 + 896e6fd commit 8ade5ba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/common/stringlist.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package common

import (
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"os"
Expand Down Expand Up @@ -28,12 +29,18 @@ func StringList(s kingpin.Settings) (target *[]string) {
return
}

type AthenaFormatter struct{}

func (f *AthenaFormatter) Format(entry *log.Entry) ([]byte, error) {
return []byte(fmt.Sprintf("%s [%s]: %s\n", entry.Time.Format("2006-01-02 15:04:05"), entry.Level.String(), entry.Message)), nil
}

func InitLogging(logLevel *string) {
kingpin.HelpFlag.Short('h')
kingpin.Parse()

// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
log.SetFormatter(&AthenaFormatter{})

// Output to stdout instead of the default stderr
// Can be any io.Writer, see below for File example
Expand Down

0 comments on commit 8ade5ba

Please sign in to comment.