Skip to content

Commit

Permalink
feat(do_backup): Add support for hiding debug logs (by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Jul 29, 2022
1 parent 719b58a commit 32ae1a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var Cmd = &cobra.Command{
FlagDisableTelemetry,
CmdFlagExtraName,
FlagJsonLogs,
true,
)
return
}
Expand All @@ -35,6 +36,7 @@ var Cmd = &cobra.Command{
FlagDisableTelemetry,
CmdFlagExtraName,
FlagJsonLogs,
true,
)
},
}
Expand Down
6 changes: 6 additions & 0 deletions do_backup/do_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func DoBackup(
telemetryDisabled bool,
extraName string,
jsonLogs bool,
debugLogs bool,
) {
if !jsonLogs {
log.Logger = log.Output(zerolog.ConsoleWriter{
Expand All @@ -32,6 +33,11 @@ func DoBackup(
})
}

zerolog.SetGlobalLevel(zerolog.InfoLevel)
if debugLogs {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

// Seed random library
rand.Seed(time.Now().UTC().UnixNano())

Expand Down
6 changes: 6 additions & 0 deletions do_backup/do_backup_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func DoBackupV2(
telemetryDisabled bool,
extraName string,
jsonLogs bool,
debugLogs bool,
) {
if !jsonLogs {
log.Logger = log.Output(zerolog.ConsoleWriter{
Expand All @@ -32,6 +33,11 @@ func DoBackupV2(
})
}

zerolog.SetGlobalLevel(zerolog.InfoLevel)
if debugLogs {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

// Seed random library
rand.Seed(time.Now().UTC().UnixNano())

Expand Down

0 comments on commit 32ae1a3

Please sign in to comment.