Skip to content

Commit

Permalink
Log version at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jun 27, 2022
1 parent 79a6ba3 commit d5a6c02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions cmd/mailroom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ import (
"github.com/sirupsen/logrus"
)

var version = "Dev"
var (
// https://goreleaser.com/cookbooks/using-main.version
version = "dev"
date = "unknown"
)

func main() {
config := runtime.NewDefaultConfig()
config.Version = version
loader := ezconf.NewLoader(
config,
"mailroom", "Mailroom - flow event handler for RapidPro",
Expand All @@ -64,18 +69,15 @@ func main() {
logrus.Fatalf("invalid config: %s", err)
}

// if we have a custom version, use it
if version != "Dev" {
config.Version = version
}

// configure our logger
logrus.SetOutput(os.Stdout)
level, err := logrus.ParseLevel(config.LogLevel)
if err != nil {
logrus.Fatalf("invalid log level '%s'", level)
}

logrus.SetLevel(level)
logrus.SetOutput(os.Stdout)
logrus.SetFormatter(&logrus.TextFormatter{})
logrus.WithField("version", version).WithField("released", date).Info("starting mailroom")

// if we have a DSN entry, try to initialize it
if config.SentryDSN != "" {
Expand Down
2 changes: 1 addition & 1 deletion mailroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (mr *Mailroom) Start() error {

// warn if we won't be doing FCM syncing
if c.FCMKey == "" {
logrus.Error("fcm not configured, no syncing of android channels")
logrus.Warn("fcm not configured, no syncing of android channels")
}

for _, initFunc := range initFunctions {
Expand Down

0 comments on commit d5a6c02

Please sign in to comment.