-
Notifications
You must be signed in to change notification settings - Fork 1
Add trace log level using debug npm package for flexible verbosity control #30
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Mossaka <[email protected]>
Co-authored-by: Mossaka <[email protected]>
|
@copilot can you pick a few scenario from the integration tests and run in the terminal and copy and past the logs to show me how differnet level of verbosity could affect the log for me to review |
I've run the command ERROR Level (Least Verbose)No awf logs shown - only container internal logs. Perfect for production when you only want to see failures. WARN LevelSame as ERROR for successful operations - would show warnings if any occurred. INFO Level (Default) - ~12 log linesShows key workflow milestones: DEBUG Level - ~25 log linesAdds detailed troubleshooting info: TRACE Level (Most Verbose) - ~35+ log linesShows all internal operations including iptables chain details and network config: Note: Currently, TRACE level shows more DEBUG messages since the codebase hasn't been instrumented with explicit logger.trace() calls yet. The infrastructure is in place for adding trace-level logging where extremely verbose output is needed (e.g., raw network packets, detailed state transitions). The full comparison document is available at |
|
@copilot please fix those |
|
@Mossaka i would rather use the "debug" package from npm to implement a very flexible trace . It's a package commonly used already, including in azure sdks |
|
@copilot use "debug" package from npm to implement a very flexible trace |
Co-authored-by: Mossaka <[email protected]>
Implemented in commit 62a88c7. The logger now uses the Key features:
Usage examples: # Simple (existing behavior)
sudo awf --log-level debug --allow-domains github.com 'command'
# Advanced (fine-grained control)
DEBUG=awf:debug,awf:trace sudo -E awf --allow-domains github.com 'command' |
Adding Trace Level to Verbosity/Tracing Configuration ✅
Summary
Successfully implemented a new "trace" log level for the awf CLI tool using the
debugnpm package for enhanced debugging and verbosity control, addressing issue #2401. The implementation uses the industry-standarddebugpackage (commonly used in Azure SDKs and many other projects) to provide both simple and advanced logging capabilities.All Requirements Met
debugpackagedebugnpm package ⭐Changes Made
Core Implementation:
src/types.ts): Added'trace'toLogLevelunion typesrc/logger.ts):debugnpm package for namespace-based loggingawf:trace,awf:debug,awf:info,awf:success,awf:warn,awf:errorLOG_LEVELShierarchy: trace=0, debug=1, info=2, warn=3, error=4trace()method with dimmed console output usingchalk.dim()--log-levelflagDEBUGenvironment variable for fine-grained controlsrc/cli.ts):--log-leveloption description to include "trace"package.json):debug(^4.4.3) as production dependency@types/debug(^4.1.12) as dev dependencyTesting:
src/logger.test.ts) with 21 testssrc/cli.test.ts)Documentation:
README.md:DEBUGenvironment variable for fine-grained controlAGENTS.md: Updated logging descriptions to mentiondebugpackage and namespace supportdocs/usage.md:DEBUGenvironment variabledocs/architecture.md: Updated logging description to mentiondebugpackage integrationLog Level Hierarchy
Benefits of Using
debugPackage--log-levelflag and advancedDEBUGenv varDEBUG=awf:debug,awf:trace)Usage Examples
Simple (backward compatible):
sudo awf --log-level debug --allow-domains github.com 'curl https://api.github.com'Advanced (fine-grained control):
Quality Assurance
✅ All 125 unit tests passing
✅ Build successful
✅ No TypeScript errors
✅ Manual testing confirms debug package integration works correctly
✅ Backward compatible with existing
--log-levelflag✅ Code review: No issues found
✅ Security scan (CodeQL): No vulnerabilities detected
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.