Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.

Commit

Permalink
adds debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Seklfreak committed Nov 17, 2021
1 parent 763b18d commit 3510ac7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ import (
"github.com/kelseyhightower/envconfig"
"github.com/pkg/errors"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func main() {
// init logger
log, err := zap.NewDevelopment()
if err != nil {
panic(errors.Wrap(err, "failed to create logger"))
}
defer log.Sync()
zap.ReplaceGlobals(log)

// parse config
var config struct {
Nordigen *nordigen.Config `envconfig:"NORDIGEN" required:"true"`
Expand All @@ -30,12 +23,27 @@ func main() {

TransactionsMap map[string]int `envconfig:"TRANSACTIONS_MAP"` // map[nordigenAccountID]lunchmoneyAssetID
BalancesMap map[string]int `envconfig:"BALANCES_MAP"` // map[nordigenAccountID]lunchmoneyAssetID

Debug bool `envconfig:"DEBUG"`
}
err = envconfig.Process("", &config)
err := envconfig.Process("", &config)
if err != nil {
log.Fatal("failed to process config", zap.Error(err))
panic(errors.Wrap(err, "failed to process config"))
}

// init logger
logOpts := make([]zap.Option, 0)
if !config.Debug {
logOpts = append(logOpts, zap.IncreaseLevel(zapcore.InfoLevel))
}

log, err := zap.NewDevelopment(logOpts...)
if err != nil {
panic(errors.Wrap(err, "failed to create logger"))
}
defer log.Sync()
zap.ReplaceGlobals(log)

// create Nordigen client
nordigenClient, err := nordigen.NewClient(
config.Nordigen,
Expand Down
2 changes: 1 addition & 1 deletion sync_trxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func syncAccount(
}

for _, trx := range lunchmoneyTransactions {
log.Info("prepared transaction", zap.Any("transaction", trx))
log.Debug("prepared transaction", zap.Any("transaction", trx))
}

// split all into chunks
Expand Down

0 comments on commit 3510ac7

Please sign in to comment.