From da9d570e1eabe77c13a32440b5ca8b639c1dfe6b Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Mon, 26 Aug 2024 11:55:33 +0300 Subject: [PATCH] make DB_DEBUG env var work Signed-off-by: Avi Deitcher --- cmd/root.go | 5 +++++ docs/configuration.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index b0a72b7c..2248d957 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -61,6 +61,10 @@ func rootCmd(execs execs) (*cobra.Command, error) { bindFlags(cmd, v) var logger = log.New() logLevel := v.GetInt("verbose") + debugSet := v.IsSet("debug") + if !v.IsSet("verbose") && (v.GetBool("debug") || (debugSet && v.GetString("debug") == "true")) { + logLevel = 1 + } switch logLevel { case 0: logger.SetLevel(log.InfoLevel) @@ -179,6 +183,7 @@ func rootCmd(execs execs) (*cobra.Command, error) { // debug via CLI or env var or default pflags.IntP("verbose", "v", 0, "set log level, 1 is debug, 2 is trace") + pflags.Bool("debug", false, "set log level to debug, equivalent of --verbose=1; if both set, --version always overrides") // aws options pflags.String("aws-endpoint-url", "", "Specify an alternative endpoint for s3 interoperable systems e.g. Digitalocean; ignored if not using s3.") diff --git a/docs/configuration.md b/docs/configuration.md index eecb41ac..248641c6 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -76,7 +76,7 @@ The following are the environment variables, CLI flags and configuration file op | what time to do the first dump or prune | BP | `dump --begin` | `DB_DUMP_BEGIN` | `dump.schedule.begin` | `0`, i.e. immediately | | cron schedule for dumps or prunes | BP | `dump --cron` | `DB_DUMP_CRON` | `dump.schedule.cron` | | | run the backup or prune a single time and exit | BP | `dump --once` | `DB_DUMP_ONCE` | `dump.schedule.once` | `false` | -| enable debug logging | BRP | `debug` | `DEBUG` | `logging` | `false` | +| enable debug logging | BRP | `debug` | `DB_DEBUG` | `logging` | `false` | | where to put the dump file; see [backup](./backup.md) | BP | `dump --target` | `DB_DUMP_TARGET` | `dump.targets` | | | where the restore file exists; see [restore](./restore.md) | R | `restore --target` | `DB_RESTORE_TARGET` | `restore.target` | | | replace any `:` in the dump filename with `-` | BP | `dump --safechars` | `DB_DUMP_SAFECHARS` | `database.safechars` | `false` |