Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

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

  • Integrated debug npm package for controlling debug logs using the standard Node.js DEBUG environment variable with support for:
    • Comma-separated areas: DEBUG=typespec:server_compile,typespec:compile_config
    • Wildcard patterns: DEBUG=typespec:*
    • Namespace hierarchies and color-coded output
  • Added dependencies:
    • debug@~4.4.0 as runtime dependency
    • @types/debug@~4.1.12 as dev dependency
  • Migrated all existing logging controls to use the DEBUG pattern:
    • typespec:server_compile (previously ENABLE_SERVER_COMPILE_LOGGING)
    • typespec:update_manager (previously ENABLE_UPDATE_MANAGER_LOGGING)
    • typespec:compile_config (previously ENABLE_COMPILE_CONFIG_LOGGING)
  • Gated debug logs in:
    • entrypoint-resolver.ts - entrypoint discovery messages (4 callsites)
    • compile-service.ts - config resolution messages (5 callsites)
    • server-compile-manager.ts - server compilation messages
    • update-manager.ts - update manager messages
    • serverlib.ts - YAML completion path (passes conditional logger to yaml-resolver.ts)
  • Updated .vscode/launch.json with DEBUG environment variable documentation and usage examples, replacing old ENABLE_*_LOGGING variable comments

Usage

Debug logs are suppressed by default. Enable when troubleshooting:

# Enable specific area
DEBUG=typespec:server_compile

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

# Enable all typespec debug logs
DEBUG=typespec:*

The debug package provides the standard Node.js debugging pattern with better performance, lazy evaluation, and widespread ecosystem adoption.

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