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

[Feature request]: Implement global debug output, and --debug=0|1|2|3 #1220

Open
mattjoyce opened this issue Dec 22, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@mattjoyce
Copy link
Contributor

What do you need?

Implement Global Debug Option

Current State

  • Debug output is inconsistent across packages
  • Some packages use hardcoded debug=false flags
  • Various packages implement their own debuglog() functions
  • Operational info goes to stdout

Proposed Solution

Add global debug level control via --debug flag in common.go

Implementation Details

  1. In common.go:
var (
    DebugLevel int  // 0-3, default 0
)

func init() {
    flag.IntVar(&DebugLevel, "debug", 0, "Debug level (0-3)")
}
  1. Create common debug function:
func DebugLog(level int, format string, args ...interface{}) {
    if level <= DebugLevel {
        fmt.Printf(format+"\n", args...)
    }
}
  1. Usage across packages:
common.DebugLog(1, "basic debug info: %v", someVar)
common.DebugLog(2, "more detailed: %v", details)
common.DebugLog(3, "trace level: %v", everything)

Migration Plan

  1. Replace existing debug=false constants with global level check
  2. Convert existing debuglog() functions to use common.DebugLog()
  3. Document debug levels in code and README:
    • 0: off (default)
    • 1: basic debug info
    • 2: detailed debugging
    • 3: trace level

Benefits

  • Consistent debug control across codebase
  • Runtime control via CLI flag
  • No additional dependencies
  • Minimal changes to existing code structure

Once this is done, revisit with increased debugging in other packages.

@mattjoyce mattjoyce added the enhancement New feature or request label Dec 22, 2024
@mattjoyce
Copy link
Contributor Author

@eugeis , unless you have something planned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant