-
Notifications
You must be signed in to change notification settings - Fork 334
Gate debug logs behind DEBUG environment variable using debug npm package
#9396
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
…ug logs Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Changed from individual ENABLE_*_LOGGING environment variables to Node.js style DEBUG pattern supporting comma-separated areas and wildcards. Usage examples: DEBUG=typespec:compile DEBUG=typespec:* DEBUG=typespec:compile,typespec:config Debug areas: - typespec:compile (previously ENABLE_SERVER_COMPILE_LOGGING) - typespec:update (previously ENABLE_UPDATE_MANAGER_LOGGING) - typespec:config (previously ENABLE_COMPILE_CONFIG_LOGGING) Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Changed debug area names to preserve the original convention: - typespec:server_compile (was typespec:compile) - typespec:update_manager (was typespec:update) - typespec:compile_config (was typespec:config) This maintains consistency with the original ENABLE_*_LOGGING variable names. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
- Added `debug` package (v4.4.0) as dependency - Added `@types/debug` as dev dependency - Replaced custom isDebugEnabled() with debug package loggers - Updated .vscode/launch.json to document DEBUG env var usage - Removed old ENABLE_*_LOGGING environment variable comments The debug package provides standard Node.js debugging with namespace support, wildcards, and better performance than the custom implementation. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
debug npm package
Added a comment to clarify that ENABLE_LM_LOGGING is separate from the DEBUG environment variable logging system and is used specifically for Language Model logging in the typespec-vscode extension. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Simplified the code by directly accessing debugLoggers.lm.enabled instead of storing it in an intermediate 'debug' variable that was only used once. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Changed provideTspconfigCompletionItems to use 'log' instead of 'logCompileConfig'. The tspconfig completion doesn't need compile config debug logging - it should use the regular log function. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
The logCompileConfig function was no longer used after reverting tspconfig completion to use the regular log function. Removed the orphaned function to clean up the code. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
|
@copilot , resolve confliction and make sure ci can pass |
- Reordered imports in constants.ts (prettier requirement) - Removed trailing whitespace in comments - Updated ThirdPartyNotices.txt with debug package attribution All formatting now passes prettier checks. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Code formatting issues resolved in commit 21ba492. Changes:
Ready for CI validation. |
| "@types/debug": "~4.1.12" | ||
| }, | ||
| "dependencies": { | ||
| "debug": "~4.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot , move this to dev dependency
|
@copilot , there is confliction needs to resolve from main branch |
The debug package is only used during development/build time for the VSCode extension, not at runtime, so it should be in devDependencies rather than dependencies. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Merge conflicts resolved in commit 1c39832. Conflicts resolved:
All tests passing after merge (entrypoint-resolver: 5/5, tspconfig completion: 118/118). |
1c39832 to
856eeb0
Compare
Plan to fix LSP spamming debug messages
ENABLE_COMPILE_CONFIG_LOGGINGto constants.tsdebugnpm packageSummary
This PR fixes the issue of LSP spamming irrelevant debug messages in the console on every compilation (which happens on nearly every keystroke with debounce).
Changes Made
Refactored to use the
debugnpm package (per review feedback):debugpackage (v4.4.0) as a dependency to@typespec/compiler(runtime)debugpackage (v4.4.0) as a devDependency totypespec-vscode(build time only)@types/debugas a dev dependency to both packagesisDebugEnabled()function with standarddebugpackage loggersDebug areas defined (preserving original naming):
typespec:server_compile- Server compilation debug logs (previouslyENABLE_SERVER_COMPILE_LOGGING)typespec:update_manager- Update manager debug logs (previouslyENABLE_UPDATE_MANAGER_LOGGING)typespec:compile_config- Compilation config debug logs (previouslyENABLE_COMPILE_CONFIG_LOGGING)typespec:lm- Language Model debug logs (previouslyENABLE_LM_LOGGING)Updated .vscode/launch.json:
Updated files in @typespec/compiler:
constants.ts- Usesdebugpackage, exportsdebugLoggersentrypoint-resolver.ts- UsesdebugLoggers.compileConfig.enabledcompile-service.ts- UsesdebugLoggers.compileConfig.enabledserver-compile-manager.ts- UsesdebugLoggers.serverCompile.enabledupdate-manager.ts- UsesdebugLoggers.updateManager.enabledserverlib.ts- Uses regularlogfunction (removed unusedlogCompileConfig)Updated files in typespec-vscode:
package.json- Addeddebugas devDependency and@types/debugas dev dependencyconst.ts- ExportsdebugLoggers.lminstead ofENABLE_LM_LOGGINGconstantlanguage-model.ts- UsesdebugLoggers.lm.enableddirectlyUpdated workspace configuration:
.vscode/launch.json- Updated comments to document unified DEBUG env var usageMerge Resolution
Successfully merged latest changes from main branch:
packages/compiler/package.jsonby accepting updated@types/babel__code-frame@~7.27.0from main while keeping@types/debug@~4.1.12additionpnpm-lock.yamlafter resolving package.json conflictsHow It Works
By default, all debug messages are suppressed. Users can enable them when troubleshooting using the standard Node.js DEBUG environment variable:
The
debugpackage provides:typespec:*)Validation
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.