Skip to content

Commit

Permalink
Merge pull request #343 from databacker/make-debug-flag-work
Browse files Browse the repository at this point in the history
make DB_DEBUG env var work
  • Loading branch information
deitch authored Aug 26, 2024
2 parents 837edad + da9d570 commit f413966
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down

0 comments on commit f413966

Please sign in to comment.