-
Notifications
You must be signed in to change notification settings - Fork 337
Gate debug logs behind TYPESPEC_DEBUG environment variable with custom implementation #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>
Changes completed in commit 9757eaf.
All tests passing (entrypoint-resolver: 5/5, tspconfig completion: 118/118). |
debug npm package- Created packages/compiler/src/server/debug.ts with debug helpers - Created packages/typespec-vscode/src/debug.ts with debug helpers - Removed debug code from constants.ts and const.ts - Updated imports in entrypoint-resolver.ts, compile-service.ts, server-compile-manager.ts, update-manager.ts to use debug.ts - Updated language-model.ts to import from debug.ts This separates debug-related code from constants, improving organization. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
|
@copilot , merge the change from main branch and make sure pipeline can pass |
Successfully merged latest changes from main branch. Updated ThirdPartyNotices.txt to remove debug package references since we're now using custom implementation without external dependencies. All builds and tests passing after merge. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Merged latest changes from main in commit bae6a68. Merge successful with no conflicts. Updated ThirdPartyNotices.txt to reflect removal of debug package. Validation completed:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
commit: |
|
@copilot , add changelog and add comment to describe why we dont use DEBUG directly (because of microsoft/vscode#290140) |
- Added changeset for @typespec/compiler and typespec-vscode - Added comments in both debug.ts files explaining that TYPESPEC_DEBUG is used instead of DEBUG because DEBUG is not supported in VSCode extensions (see microsoft/vscode#290140) This provides context for future maintainers about the design decision. Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Completed in commit f0f7b6e.
The design rationale is now documented for future maintainers. |
|
You can try these changes here
|
| * Note: We use TYPESPEC_DEBUG instead of DEBUG because the DEBUG environment variable | ||
| * is not supported in VSCode extensions. See: https://github.com/microsoft/vscode/issues/290140 | ||
| * | ||
| * Usage: TYPESPEC_DEBUG=typespec:server_compile,typespec:compile_config |
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.
As it looks like DEBUG will never work with vscode from the issue coment, do you think we still need the typespec: prefix?
Could the area also try to follow the pattern we have for tracing for consitency(Use . instead of _) service.compile service.config
Plan to fix LSP spamming debug messages
ENABLE_COMPILE_CONFIG_LOGGINGto constants.tsSummary
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
Implemented custom debug logging with TYPESPEC_DEBUG environment variable:
isDebugEnabled()function in dedicateddebug.tsfilesdebugnpm package)TYPESPEC_DEBUGenvironment variable (compatible with VSCode)Debug 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 files in @typespec/compiler:
src/server/debug.ts- NEW: Implements customisDebugEnabled(), exportsdebugLoggers, documents why TYPESPEC_DEBUG is usedsrc/server/constants.ts- Removed debug code (now in debug.ts)src/server/entrypoint-resolver.ts- ImportsdebugLoggersfrom debug.tssrc/server/compile-service.ts- ImportsdebugLoggersfrom debug.tssrc/server/server-compile-manager.ts- ImportsdebugLoggersfrom debug.tssrc/server/update-manager.ts- ImportsdebugLoggersfrom debug.tssrc/server/serverlib.ts- Uses regularlogfunctionpackage.json- No debug package dependencyUpdated files in typespec-vscode:
src/debug.ts- NEW: Implements customisDebugEnabled(), exportsdebugLoggers.lm, documents why TYPESPEC_DEBUG is usedsrc/const.ts- Removed debug code (now in debug.ts)src/lm/language-model.ts- ImportsdebugLoggersfrom debug.tspackage.json- No debug package dependencyThirdPartyNotices.txt- Removed debug package attributionUpdated workspace configuration:
.vscode/launch.json- Updated comments to document TYPESPEC_DEBUG env var usageAdded changelog:
Why TYPESPEC_DEBUG Instead of DEBUG?
The standard Node.js
DEBUGenvironment variable is not supported in VSCode extensions due to how VSCode handles environment variables. See VSCode issue #290140 for details. Therefore, we useTYPESPEC_DEBUGas a TypeSpec-specific alternative that works correctly in both the compiler and VSCode extension contexts.Merge from Main
Successfully merged latest changes from main branch with no conflicts. Updated dependencies and third-party notices accordingly.
How It Works
By default, all debug messages are suppressed. Users can enable them when troubleshooting using the TYPESPEC_DEBUG environment variable:
The custom implementation 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.