-
Notifications
You must be signed in to change notification settings - Fork 331
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>
| */ | ||
| export const ENABLE_SERVER_COMPILE_LOGGING = "ENABLE_SERVER_COMPILE_LOGGING"; | ||
| export const ENABLE_UPDATE_MANAGER_LOGGING = "ENABLE_UPDATE_MANAGER_LOGGING"; | ||
| export const ENABLE_COMPILE_CONFIG_LOGGING = "ENABLE_COMPILE_CONFIG_LOGGING"; |
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.
let's change to use DEBUG=area1,area2 in nodejs pattern for this, please also change the other enable...logging enviornment variable too.
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 , let's change to use DEBUG=area1,area2 in nodejs pattern instead of individual env var for this, please also change the other enable...logging enviornment variable too.
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.
Changed to use Node.js DEBUG pattern in commit 94bf93f.
Now uses DEBUG=typespec:compile,typespec:config instead of individual environment variables. Supports wildcards like DEBUG=typespec:*.
All three existing logging areas have been migrated:
typespec:compile(was ENABLE_SERVER_COMPILE_LOGGING)typespec:update(was ENABLE_UPDATE_MANAGER_LOGGING)typespec:config(was ENABLE_COMPILE_CONFIG_LOGGING)
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>
| export const DebugAreas = { | ||
| SERVER_COMPILE: "typespec:compile", | ||
| UPDATE_MANAGER: "typespec:update", | ||
| COMPILE_CONFIG: "typespec: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.
@copilot keep the original string between enable and logging, i.e. server_compile -> "typespec::server_compile
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.
Updated to preserve original naming in commit b4bcd2d.
Debug areas now use:
typespec:server_compiletypespec:update_managertypespec:compile_config
| * DEBUG=typespec:* | ||
| * DEBUG=typespec:compile,typespec:config | ||
| */ | ||
| export function isDebugEnabled(area: string): boolean { |
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 reuse existing common package like 'debug'
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.
Refactored to use the debug npm package in commit 451c4e0.
Changes:
- Added
debug@~4.4.0and@types/debug@~4.1.12as dependencies - Replaced custom
isDebugEnabled()with standard debug package loggers - All files now use
debugLoggers.*.enabledto check if debugging is active
The debug package provides standard Node.js debugging with wildcards, namespaces, and better performance.
| SERVER_COMPILE: "typespec:compile", | ||
| UPDATE_MANAGER: "typespec:update", | ||
| COMPILE_CONFIG: "typespec:config", | ||
| } as const; |
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 , also updated related comment in the launch file in vscode workspace
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.
Updated .vscode/launch.json in commit 451c4e0.
Replaced old environment variable comments (ENABLE_SERVER_COMPILE_LOGGING, ENABLE_UPDATE_MANAGER_LOGGING) with DEBUG pattern documentation showing usage examples:
DEBUG=typespec:server_compilefor specific areasDEBUG=typespec:*for all areasDEBUG=typespec:server_compile,typespec:compile_configfor multiple areas
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
LSP was emitting debug messages on every compilation (~every keystroke), cluttering the console with messages like "main file found using client provided entrypoint" and config resolution details.
Changes
debugnpm package for controlling debug logs using the standard Node.jsDEBUGenvironment variable with support for:DEBUG=typespec:server_compile,typespec:compile_configDEBUG=typespec:*debug@~4.4.0as runtime dependency@types/debug@~4.1.12as dev dependencytypespec:server_compile(previouslyENABLE_SERVER_COMPILE_LOGGING)typespec:update_manager(previouslyENABLE_UPDATE_MANAGER_LOGGING)typespec:compile_config(previouslyENABLE_COMPILE_CONFIG_LOGGING)entrypoint-resolver.ts- entrypoint discovery messages (4 callsites)compile-service.ts- config resolution messages (5 callsites)server-compile-manager.ts- server compilation messagesupdate-manager.ts- update manager messagesserverlib.ts- YAML completion path (passes conditional logger toyaml-resolver.ts).vscode/launch.jsonwith DEBUG environment variable documentation and usage examples, replacing oldENABLE_*_LOGGINGvariable commentsUsage
Debug logs are suppressed by default. Enable when troubleshooting:
The
debugpackage provides the standard Node.js debugging pattern with better performance, lazy evaluation, and widespread ecosystem adoption.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.