Skip to content

Commit e0e19db

Browse files
committed
Merge branch 'master' into release
2 parents cd4cddc + 5c1ffd6 commit e0e19db

File tree

31 files changed

+195
-45
lines changed

31 files changed

+195
-45
lines changed

.github/ISSUE_TEMPLATE/1-bug.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ labels: 'type: bug'
3232

3333
**For VS Code users:**
3434

35-
1. Open Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
36-
2. Go to `View: Toggle Output`
37-
3. Select `Nx Console` from the dropdown
38-
4. Also select `Nx Language Server` from the dropdown
39-
5. Paste both outputs below
35+
1. Enable debug logging (recommended for detailed logs):
36+
- Open Settings (`Ctrl+,` / `Cmd+,`)
37+
- Search for `nxConsole.enableDebugLogging`
38+
- Enable the setting
39+
- Restart VS Code or reload the window (`Ctrl+Shift+P` / `Cmd+Shift+P``Developer: Reload Window`)
40+
2. Reproduce the issue
41+
3. Open Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
42+
4. Go to `View: Toggle Output`
43+
5. Select `Nx Console` from the dropdown
44+
6. Also select `Nx Language Server` from the dropdown
45+
7. Paste both outputs below
4046

4147
**For JetBrains IDE users (IntelliJ, WebStorm, etc.):**
4248

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ When debugging the JCEF-based generate UI, you can attach an instance of Chrome
3737

3838
### Building the extension for local testing
3939

40+
### Debugging
41+
42+
When developing or troubleshooting issues, you can enable debug logging to get detailed output:
43+
44+
#### VSCode
45+
46+
1. Open Settings (`Ctrl+,` / `Cmd+,`)
47+
2. Search for `nxConsole.enableDebugLogging`
48+
3. Enable the setting
49+
4. Restart VS Code or reload the window (`Ctrl+Shift+P` / `Cmd+Shift+P``Developer: Reload Window`)
50+
5. View logs in the Output panel:
51+
- Open Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
52+
- Go to `View: Toggle Output`
53+
- Select `Nx Console` and `Nx Language Server` from the dropdown
54+
55+
#### IntelliJ
56+
57+
1. Go to `Help``Diagnostic Tools``Debug Log Settings...`
58+
2. Add: `#dev.nx.console:trace`
59+
3. Click `OK` and restart the IDE
60+
4. Access logs via `Help``Show Log in Explorer` (Windows) / `Show Log in Finder` (macOS) / `Show Log in Files` (Linux)
61+
5. Look for the `idea.log` file
62+
4063
## Submitting a PR
4164

4265
Please follow the following guidelines:

apps/nx-mcp/src/main.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ async function main() {
5555
);
5656

5757
let mcpStdioConnected = false;
58-
let logger: { log: (message: string) => void } = consoleLogger;
58+
let logger: {
59+
log: (message: string) => void;
60+
debug?: (message: string) => void;
61+
} = consoleLogger;
5962

6063
if (argv.transport === 'stdio') {
6164
logger = {
@@ -69,8 +72,25 @@ async function main() {
6972
// do nothing
7073
}
7174
},
75+
debug: (data: string) => {
76+
if (argv.debugLogs && mcpStdioConnected) {
77+
mcpServer.server.sendLoggingMessage({
78+
level: 'info',
79+
data,
80+
});
81+
}
82+
},
7283
};
7384
ensureOnlyJsonRpcStdout();
85+
} else {
86+
logger = {
87+
log: consoleLogger.log,
88+
debug: (message: string) => {
89+
if (argv.debugLogs) {
90+
consoleLogger.log?.(message);
91+
}
92+
},
93+
};
7494
}
7595

7696
logger.log('Starting Nx MCP server');

apps/nx-mcp/src/yargs-config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface ArgvType {
88
port?: number;
99
disableTelemetry: boolean;
1010
keepAliveInterval: number;
11+
debugLogs: boolean;
1112
_: (string | number)[];
1213
$0: string;
1314
[x: string]: unknown;
@@ -59,6 +60,11 @@ export function createYargsConfig(args: string[]): Argv<any> {
5960
hidden: true,
6061
default: 30000,
6162
})
63+
.option('debugLogs', {
64+
describe: 'Enable debug logging',
65+
type: 'boolean',
66+
default: false,
67+
})
6268
.check((argv) => {
6369
// Check for conflicting options
6470
if (argv.sse && argv.transport === 'http') {

apps/nxls/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ const documents = new TextDocuments(TextDocument);
134134
documents.listen(connection);
135135

136136
connection.onInitialize(async (params) => {
137-
setLspLogger(connection);
137+
const { workspacePath, enableDebugLogging } =
138+
params.initializationOptions ?? {};
139+
setLspLogger(connection, enableDebugLogging ?? false);
138140
lspLogger.log('Initializing Nx Language Server');
139-
140-
const { workspacePath } = params.initializationOptions ?? {};
141141
try {
142142
WORKING_PATH =
143143
workspacePath ||

apps/vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,11 @@
10781078
"type": "number",
10791079
"scope": "resource",
10801080
"description": "Fixed port for the Nx MCP server. If set to 0, a random available port will be used."
1081+
},
1082+
"nxConsole.enableDebugLogging": {
1083+
"type": "boolean",
1084+
"default": false,
1085+
"description": "Enable debug logging in Nx Console output channels and the Nx Language Server."
10811086
}
10821087
}
10831088
},

apps/vscode/src/main.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@ import {
1212
workspace,
1313
} from 'vscode';
1414

15+
import { killGroup, withTimeout } from '@nx-console/shared-utils';
1516
import {
16-
killGroup,
17-
loadRootEnvFiles,
18-
withTimeout,
19-
} from '@nx-console/shared-utils';
20-
import {
21-
getNxWorkspacePath,
2217
GlobalConfigurationStore,
2318
WorkspaceConfigurationStore,
2419
} from '@nx-console/vscode-configuration';
@@ -65,6 +60,7 @@ import {
6560
hasNxGraphServer,
6661
hasNxGraphServerAffected,
6762
} from '@nx-console/vscode-graph-base';
63+
import { initMessagingServer } from '@nx-console/vscode-messaging';
6864
import { initNvmTip } from '@nx-console/vscode-nvm-tip';
6965
import {
7066
handleSelfHealingUri,
@@ -80,7 +76,6 @@ import { getTelemetry, initTelemetry } from '@nx-console/vscode-telemetry';
8076
import { RequestType } from 'vscode-languageserver';
8177
import { initNxInit } from './nx-init';
8278
import { registerRefreshWorkspace } from './refresh-workspace';
83-
import { initMessagingServer } from '@nx-console/vscode-messaging';
8479

8580
let nxProjectsTreeProvider: NxProjectTreeProvider;
8681

apps/vscode/src/nx-init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function initNxInit(context: ExtensionContext) {
2828
const workspacePath =
2929
workspace.workspaceFolders &&
3030
workspace.workspaceFolders[0].uri.fsPath;
31-
const provenanceResult = await nxLatestProvenanceCheck();
31+
const provenanceResult = await nxLatestProvenanceCheck(workspacePath);
3232
if (provenanceResult !== true) {
3333
getTelemetry().logUsage('misc.nx-latest-no-provenance');
3434
logAndShowError(noProvenanceError, provenanceResult);

libs/language-server/utils/src/lib/lsp-log.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { Logger } from '@nx-console/shared-utils';
22
import { Connection } from 'vscode-languageserver';
33

44
let log: Console['log'] | undefined;
5+
let enableDebugLogging = false;
56

6-
export function setLspLogger(connection: Connection) {
7+
export function setLspLogger(connection: Connection, debugLogging = false) {
78
if (!log) {
89
log = connection.console.log.bind(connection.console);
10+
enableDebugLogging = debugLogging;
911
} else {
1012
throw `Can't set logger twice`;
1113
}
@@ -18,4 +20,12 @@ export const lspLogger: Logger = {
1820
...args,
1921
);
2022
},
23+
debug(message: string, ...args: any[]) {
24+
if (enableDebugLogging) {
25+
log?.(
26+
`[Nxls] - ${new Date(Date.now()).toISOString()} - ${message}\n`,
27+
...args,
28+
);
29+
}
30+
},
2131
};
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
22
import { Logger } from '@nx-console/shared-utils';
33

4-
export function getMcpLogger(server: McpServer): Logger {
4+
export function getMcpLogger(
5+
server: McpServer,
6+
enableDebugLogging = false,
7+
): Logger {
58
return {
69
log: (message: string) => {
710
server.server.sendLoggingMessage({
811
level: 'info',
912
data: message,
1013
});
1114
},
15+
debug: (message: string) => {
16+
if (enableDebugLogging) {
17+
server.server.sendLoggingMessage({
18+
level: 'info',
19+
data: message,
20+
});
21+
}
22+
},
1223
};
1324
}

0 commit comments

Comments
 (0)