Skip to content

Commit

Permalink
Merge pull request #13 from worldcoin/wip/mk/improve-logs
Browse files Browse the repository at this point in the history
Allow for json logging
  • Loading branch information
kustosz authored Jan 6, 2023
2 parents 2e5362c + c887f28 commit 8f45b4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions logging/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logging

import (
gnarkLogger "github.com/consensys/gnark/logger"
"github.com/rs/zerolog"
"os"
)
Expand All @@ -10,3 +11,8 @@ var log = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: "15:04:0
func Logger() *zerolog.Logger {
return &log
}

func SetJSONOutput() {
log = zerolog.New(os.Stdout).With().Timestamp().Logger()
gnarkLogger.Set(log)
}
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ func main() {
Name: "start",
Flags: []cli.Flag{
&cli.StringFlag{Name: "keys-file", Usage: "proving system file", Required: true},
&cli.BoolFlag{Name: "json-logging", Usage: "enable JSON logging", Required: false},
&cli.StringFlag{Name: "prover-address", Usage: "address for the prover server", Value: "localhost:3001", Required: false},
&cli.StringFlag{Name: "metrics-address", Usage: "address for the metrics server", Value: "localhost:9998", Required: false},
},
Action: func(context *cli.Context) error {
if context.Bool("json-logging") {
logging.SetJSONOutput()
}
keys := context.String("keys-file")
logging.Logger().Info().Msg("Reading proving system from file")
ps, err := prover.ReadSystemFromFile(keys)
if err != nil {
return err
Expand Down

0 comments on commit 8f45b4e

Please sign in to comment.