Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility support for --debug flag from docker #15317

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ var (
DisableFlagsInUseLine: true,
}

logLevel = "warn"
defaultLogLevel = "warn"
logLevel = defaultLogLevel
debug bool

useSyslog bool
requireCleanup = true
)
Expand Down Expand Up @@ -310,6 +313,13 @@ func persistentPostRunE(cmd *cobra.Command, args []string) error {

func loggingHook() {
var found bool
if debug {
if logLevel != defaultLogLevel {
fmt.Fprintf(os.Stderr, "Setting --log-level and --debug is not allowed\n")
os.Exit(1)
}
logLevel = "debug"
}
for _, l := range common.LogLevels {
if l == strings.ToLower(logLevel) {
found = true
Expand Down Expand Up @@ -465,6 +475,9 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
pFlags.StringVar(&logLevel, logLevelFlagName, logLevel, fmt.Sprintf("Log messages above specified level (%s)", strings.Join(common.LogLevels, ", ")))
_ = rootCmd.RegisterFlagCompletionFunc(logLevelFlagName, common.AutocompleteLogLevel)

pFlags.BoolVar(&debug, "debug", false, "Docker compatibility, force setting of log-level")
_ = pFlags.MarkHidden("debug")

// Only create these flags for ABI connections
if !registry.IsRemote() {
runtimeflagFlagName := "runtime-flag"
Expand Down
3 changes: 3 additions & 0 deletions test/system/001-basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ See 'podman version --help'" "podman version --remote"
run_podman --log-level=error info
run_podman --log-level=fatal info
run_podman --log-level=panic info
run_podman --debug info
run_podman 1 --debug --log-level=panic info
is "$output" "Setting --log-level and --debug is not allowed"
}

# vim: filetype=sh