From 0b5a1d94c99db674e33d3b7688c43ec40c32376d Mon Sep 17 00:00:00 2001 From: taobig Date: Fri, 16 Aug 2024 20:52:03 +0800 Subject: [PATCH] Ensure that the name of the log file is consistent in the help doc and in the code. --- cmd/main.go | 2 +- launcher/logging.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 7c0793d..759dffd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -72,7 +72,7 @@ func Main[B firecore.Block](chain *firecore.Chain[B]) { flags.StringP("config-file", "c", "./firehose.yaml", "Configuration file to use. No config file loaded if set to an empty string.") flags.String("log-format", "text", "Format for logging to stdout. Either 'text' or 'stackdriver'") - flags.Bool("log-to-file", true, "Also write logs to {data-dir}/firehose.log.json ") + flags.Bool("log-to-file", true, fmt.Sprintf("Also write logs to {data-dir}/%s ", launcher.DefaultLogFile)) flags.String("log-level-switcher-listen-addr", "localhost:1065", cli.FlagDescription(` If non-empty, a JSON based HTTP server will listen on this address to let you switch the default logging level of all registered loggers to a different one on the fly. This enables switching to debug level on diff --git a/launcher/logging.go b/launcher/logging.go index 90bca97..6b9653f 100644 --- a/launcher/logging.go +++ b/launcher/logging.go @@ -21,6 +21,8 @@ import ( "go.uber.org/zap" ) +const DefaultLogFile = "app.log.json" + type LoggingOptions struct { WorkingDir string // the folder where the data will be stored, in our case will be used to store the logger Verbosity int // verbosity level @@ -50,7 +52,7 @@ func SetupLogger(rootLogger *zap.Logger, opts *LoggingOptions) { } if opts.LogToFile { - options = append(options, logging.WithOutputToFile(filepath.Join(opts.WorkingDir, "app.log.json"))) + options = append(options, logging.WithOutputToFile(filepath.Join(opts.WorkingDir, DefaultLogFile))) } logging.InstantiateLoggers(options...)