Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Summary

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 debug npm package (per review feedback):

  • Added debug package (v4.4.0) as a dependency to both @typespec/compiler and typespec-vscode
  • Added @types/debug as a dev dependency to both packages
  • Replaced custom isDebugEnabled() function with standard debug package loggers
  • Created debug loggers for each area

Debug areas defined (preserving original naming):

  • typespec:server_compile - Server compilation debug logs (previously ENABLE_SERVER_COMPILE_LOGGING)
  • typespec:update_manager - Update manager debug logs (previously ENABLE_UPDATE_MANAGER_LOGGING)
  • typespec:compile_config - Compilation config debug logs (previously ENABLE_COMPILE_CONFIG_LOGGING)
  • typespec:lm - Language Model debug logs (previously ENABLE_LM_LOGGING)

Updated .vscode/launch.json:

  • Replaced old environment variable comments with unified DEBUG pattern documentation
  • Added usage examples showing how to enable different debug areas including LM logging
  • All logging now uses the unified DEBUG environment variable

Updated files in @typespec/compiler:

  1. constants.ts - Uses debug package, exports debugLoggers
  2. entrypoint-resolver.ts - Uses debugLoggers.compileConfig.enabled
  3. compile-service.ts - Uses debugLoggers.compileConfig.enabled
  4. server-compile-manager.ts - Uses debugLoggers.serverCompile.enabled
  5. update-manager.ts - Uses debugLoggers.updateManager.enabled
  6. serverlib.ts - Uses debugLoggers.compileConfig.enabled

Updated files in typespec-vscode:

  1. package.json - Added debug dependency and @types/debug dev dependency
  2. const.ts - Exports debugLoggers.lm instead of ENABLE_LM_LOGGING constant
  3. language-model.ts - Uses debugLoggers.lm.enabled instead of checking environment variable

Updated workspace configuration:

  • .vscode/launch.json - Updated comments to document unified DEBUG env var usage

How It Works

By default, all debug messages are suppressed. Users can enable them when troubleshooting using the standard Node.js DEBUG environment variable:

# Enable specific area
DEBUG=typespec:server_compile

# Enable Language Model logs
DEBUG=typespec:lm

# Enable all typespec debug logs
DEBUG=typespec:*

# Enable multiple specific areas
DEBUG=typespec:server_compile,typespec:compile_config,typespec:lm

The debug package provides:

  • Standard Node.js debugging pattern
  • Wildcard support (typespec:*)
  • Namespace hierarchies
  • Better performance with lazy evaluation
  • Color-coded output in terminals
  • Widespread adoption and maintenance

Test Results

  • ✅ All existing tests pass
  • ✅ Entrypoint resolver tests: 5/5 passing
  • ✅ TSPConfig completion tests: 118/118 passing
  • ✅ Full build successful
  • ✅ typespec-vscode type checking passes
Original prompt

This section details on the original issue you should resolve

<issue_title>LSP spamming irrelevent debug message in console</issue_title>
<issue_description>Image

Multiple message show up on every compilation which happens about every keypress(with debounce)</issue_description>

<agent_instructions>the env var 'ENABLE_SERVER_COMPILE_LOGGING' and 'ENABLE_UPDATE_MANAGER_LOGGING' can be used as an example. use the same way to control the log around the configuration of server compile</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@RodgeFu Consider disabling them by default and have an env var (ENABLE_COMPILE_CONFIG_LOGGING) to enable it when needed (i.e. when troubleshooting compile related issues). Just like what we do with 'ENABLE_UPDATE_MANAGER_LOGGING'

💡 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.

Copilot AI and others added 2 commits January 16, 2026 11:16
…ug logs

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix LSP spamming irrelevant debug messages Gate compilation config debug logs behind ENABLE_COMPILE_CONFIG_LOGGING Jan 16, 2026
Copilot AI requested a review from RodgeFu January 16, 2026 11:30
*/
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";
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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>
Copilot AI changed the title Gate compilation config debug logs behind ENABLE_COMPILE_CONFIG_LOGGING Gate debug logs behind DEBUG environment variable using Node.js pattern Jan 17, 2026
Copilot AI requested a review from RodgeFu January 17, 2026 05:21
export const DebugAreas = {
SERVER_COMPILE: "typespec:compile",
UPDATE_MANAGER: "typespec:update",
COMPILE_CONFIG: "typespec:config",
Copy link
Contributor

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

Copy link
Contributor Author

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_compile
  • typespec:update_manager
  • typespec:compile_config

* DEBUG=typespec:*
* DEBUG=typespec:compile,typespec:config
*/
export function isDebugEnabled(area: string): boolean {
Copy link
Contributor

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'

Copy link
Contributor Author

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.0 and @types/debug@~4.1.12 as dependencies
  • Replaced custom isDebugEnabled() with standard debug package loggers
  • All files now use debugLoggers.*.enabled to 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;
Copy link
Contributor

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

Copy link
Contributor Author

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_compile for specific areas
  • DEBUG=typespec:* for all areas
  • DEBUG=typespec:server_compile,typespec:compile_config for 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>
Copilot AI changed the title Gate debug logs behind DEBUG environment variable using Node.js pattern Gate debug logs behind DEBUG environment variable using debug npm package Jan 17, 2026
// "DEBUG": "typespec:*" - Enable all typespec debug logs
// "DEBUG": "typespec:server_compile,typespec:compile_config" - Enable multiple areas
//"DEBUG": "typespec:server_compile,typespec:update_manager,typespec:compile_config",
//"ENABLE_LM_LOGGING": "true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , you missed the enable_lm_logging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added documentation for ENABLE_LM_LOGGING in commit ca30a74.

Added a comment clarifying 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot , also do the same refactor to use debug log area for the code in typespec-vscode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored typespec-vscode to use the debug package in commit 42c1d4f.

Changes:

  • Added debug@~4.4.0 and @types/debug@~4.1.12 to typespec-vscode
  • Replaced ENABLE_LM_LOGGING with debugLoggers.lm using namespace typespec:lm
  • Updated .vscode/launch.json to document DEBUG=typespec:lm usage

Language Model logging now follows the same DEBUG pattern as compiler logging. Enable with DEBUG=typespec:lm or DEBUG=typespec:*

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>
Copilot AI requested a review from RodgeFu January 19, 2026 06:20
- Added `debug@~4.4.0` as dependency to typespec-vscode
- Added `@types/debug@~4.1.12` as dev dependency
- Replaced ENABLE_LM_LOGGING with debug logger (typespec:lm)
- Updated const.ts to export debugLoggers.lm
- Updated language-model.ts to use debugLoggers.lm.enabled
- Updated .vscode/launch.json to document DEBUG=typespec:lm usage

Language Model logging now follows the same DEBUG pattern as compiler
logging, enabling it with DEBUG=typespec:lm or DEBUG=typespec:*

Co-authored-by: RodgeFu <6038235+RodgeFu@users.noreply.github.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.

LSP spamming irrelevent debug message in console

2 participants