Skip to content

Add verbose logging control with --verbose flag#20

Open
tzermias wants to merge 1 commit into
mainfrom
feature/add-verbosity-control
Open

Add verbose logging control with --verbose flag#20
tzermias wants to merge 1 commit into
mainfrom
feature/add-verbosity-control

Conversation

@tzermias

Copy link
Copy Markdown
Owner

Summary

Implements Phase 1 of the interactive progress and verbosity control plan:
a global --verbose / -v flag to control debug output visibility.

  • New pkg/logger package with thread-safe conditional logging
  • Added --verbose / -v persistent flag to root command
  • Replaced all log.Printf calls with logger.Printf throughout codebase
  • Debug logs suppressed by default, enabled with --verbose
  • Error messages always display regardless of verbose mode

Test Plan

  • Unit tests pass (make test) - 5 new tests in pkg/logger
  • Integration tested: --verbose and -v flags work correctly
  • Code formatted (make fmt)
  • Static analysis clean (make vet)
  • Binary builds successfully (make build)

Usage

# Default (quiet) - debug logs suppressed
deskctl goto-height 100

# Verbose mode - shows debug logs
deskctl --verbose goto-height 100
deskctl -v goto-height 100

🤖 Generated with Claude Code

Implements Phase 1 of the interactive progress and verbosity plan:
global --verbose/-v flag to control debug output visibility.

Changes:
- New pkg/logger package with thread-safe conditional logging
- Added --verbose/-v persistent flag to root command
- Replaced all log.Printf calls with logger.Printf throughout codebase
- Debug logs now suppressed by default, enabled with --verbose
- Error messages always display regardless of verbose mode

Features:
- SetVerbose(bool) to enable/disable verbose logging
- Printf/Println only print when verbose is enabled
- Error/Errorf always print (regardless of verbose setting)
- Thread-safe with sync.RWMutex for concurrent access
- Comprehensive test coverage (5 tests, all passing)

Files modified:
- cmd/root.go: Added --verbose flag and logger integration
- pkg/jiecang/jiecang.go: Switched to logger.Printf (3 calls)
- pkg/jiecang/memory.go: Switched to logger.Printf (1 call)
- hack/test.go: Switched to logger package with verbose enabled

New files:
- pkg/logger/logger.go: Conditional logging implementation
- pkg/logger/logger_test.go: Test suite with 5 tests

Testing:
- All unit tests pass (make test)
- Integration test confirms --verbose/-v flags work correctly
- Code formatted (make fmt) and vetted (make vet)
- Binary build successful (make build)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant