Skip to content

Commit

Permalink
Merge pull request #145 from nicolasbock/refactor
Browse files Browse the repository at this point in the history
Split logging and parsing
  • Loading branch information
nicolasbock authored May 17, 2024
2 parents a41b0ac + 9ff08ee commit a2538ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
)

func init() {
common.ParseCommandline()
common.InitLogging(logLevel)
}

Expand Down
1 change: 1 addition & 0 deletions cmd/processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
)

func init() {
common.ParseCommandline()
common.InitLogging(logLevel)
}

Expand Down
9 changes: 6 additions & 3 deletions pkg/common/stringlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package common

import (
"fmt"
log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"os"
"strings"

log "github.com/sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
)

type stringList []string
Expand Down Expand Up @@ -35,10 +36,12 @@ 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) {
func ParseCommandline() {
kingpin.HelpFlag.Short('h')
kingpin.Parse()
}

func InitLogging(logLevel *string) {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&AthenaFormatter{})

Expand Down

0 comments on commit a2538ba

Please sign in to comment.