diff --git a/.changeset/modern-gorillas-walk.md b/.changeset/modern-gorillas-walk.md new file mode 100644 index 0000000000000..12cc2f00f519d --- /dev/null +++ b/.changeset/modern-gorillas-walk.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/batch-submitter-service': patch +--- + +Default to JSON logs, add LOG_TERMINAL flag for debugging diff --git a/go/batch-submitter/batch_submitter.go b/go/batch-submitter/batch_submitter.go index d0b8c7992e2c6..a542ae312ff56 100644 --- a/go/batch-submitter/batch_submitter.go +++ b/go/batch-submitter/batch_submitter.go @@ -54,9 +54,11 @@ func Main(gitVersion string) func(ctx *cli.Context) error { return err } - logHandler = bsscore.SentryStreamHandler(os.Stdout, log.TerminalFormat(true)) - } else { + logHandler = bsscore.SentryStreamHandler(os.Stdout, log.JSONFormat()) + } else if cfg.LogTerminal { logHandler = log.StreamHandler(os.Stdout, log.TerminalFormat(true)) + } else { + logHandler = log.StreamHandler(os.Stdout, log.JSONFormat()) } logLevel, err := log.LvlFromString(cfg.LogLevel) diff --git a/go/batch-submitter/config.go b/go/batch-submitter/config.go index ecb47e244c7c9..e4a10f6e37728 100644 --- a/go/batch-submitter/config.go +++ b/go/batch-submitter/config.go @@ -118,6 +118,11 @@ type Config struct { // LogLevel is the lowest log level that will be output. LogLevel string + // LogTerminal if true, prints to stdout in terminal format, otherwise + // prints using JSON. If SentryEnable is true this flag is ignored, and logs + // are printed using JSON. + LogTerminal bool + // SentryEnable if true, logs any error messages to sentry. SentryDsn // must also be set if SentryEnable is true. SentryEnable bool @@ -191,6 +196,7 @@ func NewConfig(ctx *cli.Context) (Config, error) { ClearPendingTxs: ctx.GlobalBool(flags.ClearPendingTxsFlag.Name), /* Optional Flags */ LogLevel: ctx.GlobalString(flags.LogLevelFlag.Name), + LogTerminal: ctx.GlobalBool(flags.LogTerminalFlag.Name), SentryEnable: ctx.GlobalBool(flags.SentryEnableFlag.Name), SentryDsn: ctx.GlobalString(flags.SentryDsnFlag.Name), SentryTraceRate: ctx.GlobalDuration(flags.SentryTraceRateFlag.Name), diff --git a/go/batch-submitter/flags/flags.go b/go/batch-submitter/flags/flags.go index c3f97c4e86d17..d19f7fb092037 100644 --- a/go/batch-submitter/flags/flags.go +++ b/go/batch-submitter/flags/flags.go @@ -129,6 +129,13 @@ var ( Value: "info", EnvVar: prefixEnvVar("LOG_LEVEL"), } + LogTerminalFlag = cli.BoolFlag{ + Name: "log-terminal", + Usage: "If true, outputs logs in terminal format, otherwise prints " + + "in JSON format. If SENTRY_ENABLE is set to true, this flag is " + + "ignored and logs are printed using JSON", + EnvVar: prefixEnvVar("LOG_TERMINAL"), + } SentryEnableFlag = cli.BoolFlag{ Name: "sentry-enable", Usage: "Whether or not to enable Sentry. If true, sentry-dsn must also be set", @@ -197,8 +204,8 @@ var ( EnvVar: prefixEnvVar("METRICS_PORT"), } HTTP2DisableFlag = cli.BoolFlag{ - Name: "http2-disable", - Usage: "Whether or not to disable HTTP/2 support.", + Name: "http2-disable", + Usage: "Whether or not to disable HTTP/2 support.", EnvVar: prefixEnvVar("HTTP2_DISABLE"), } ) @@ -224,6 +231,7 @@ var requiredFlags = []cli.Flag{ var optionalFlags = []cli.Flag{ LogLevelFlag, + LogTerminalFlag, SentryEnableFlag, SentryDsnFlag, SentryTraceRateFlag, diff --git a/ops/envs/batch-submitter.env b/ops/envs/batch-submitter.env index a49a81e186899..7261255a8420e 100644 --- a/ops/envs/batch-submitter.env +++ b/ops/envs/batch-submitter.env @@ -3,6 +3,7 @@ ETH_NETWORK_NAME=clique LOG_LEVEL=debug BATCH_SUBMITTER_LOG_LEVEL=debug +BATCH_SUBMITTER_LOG_TERMINAL=true BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000 BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0 BATCH_SUBMITTER_POLL_INTERVAL=500ms