Skip to content

Commit 8078c34

Browse files
committed
Improve logging
1 parent 12b3a71 commit 8078c34

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/extension.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function activate(context: ExtensionContext) {
4949
const uri = folder.uri.toString();
5050
client.info(`Deleting folder for clients: ${uri}`);
5151
clients.delete(uri);
52-
client.info('Stopping the client');
52+
client.info('Stopping the server');
5353
client.stop();
5454
}
5555
}
@@ -58,9 +58,9 @@ export async function activate(context: ExtensionContext) {
5858
// Register editor commands for HIE, but only register the commands once at activation.
5959
const restartCmd = commands.registerCommand(CommandNames.RestartServerCommandName, async () => {
6060
for (const langClient of clients.values()) {
61-
langClient?.info('Stopping the client');
61+
langClient?.info('Stopping the server');
6262
await langClient?.stop();
63-
langClient?.info('Starting the client');
63+
langClient?.info('Starting the server');
6464
langClient?.start();
6565
}
6666
});
@@ -69,19 +69,19 @@ export async function activate(context: ExtensionContext) {
6969

7070
const stopCmd = commands.registerCommand(CommandNames.StopServerCommandName, async () => {
7171
for (const langClient of clients.values()) {
72-
langClient?.info('Stopping the client');
72+
langClient?.info('Stopping the server');
7373
await langClient?.stop();
74-
langClient?.info('Client stopped');
74+
langClient?.info('Server stopped');
7575
}
7676
});
7777

7878
context.subscriptions.push(stopCmd);
7979

8080
const startCmd = commands.registerCommand(CommandNames.StartServerCommandName, async () => {
8181
for (const langClient of clients.values()) {
82-
langClient?.info('Starting the client');
82+
langClient?.info('Starting the server');
8383
langClient?.start();
84-
langClient?.info('Client started');
84+
langClient?.info('Server started');
8585
}
8686
});
8787

@@ -118,10 +118,10 @@ function findManualExecutable(logger: Logger, uri: Uri, folder?: WorkspaceFolder
118118
/** Searches the PATH for whatever is set in serverVariant */
119119
function findLocalServer(context: ExtensionContext, logger: Logger, uri: Uri, folder?: WorkspaceFolder): string | null {
120120
const exes: string[] = ['haskell-language-server-wrapper', 'haskell-language-server'];
121-
logger.info(`Searching for server executables ${exes.join(' ')} in PATH`);
121+
logger.info(`Searching for server executables ${exes.join(',')} in $PATH`);
122122
for (const exe of exes) {
123123
if (executableExists(exe)) {
124-
logger.info(`Found server executable in PATH: ${exe}`);
124+
logger.info(`Found server executable in $PATH: ${exe}`);
125125
return exe;
126126
}
127127
}
@@ -178,7 +178,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
178178
}
179179
} catch (e) {
180180
if (e instanceof Error) {
181-
logger.error('Error getting the server executable: ${e.message}');
181+
logger.error(`Error getting the server executable: ${e.message}`);
182182
window.showErrorMessage(e.message);
183183
}
184184
return;
@@ -197,6 +197,12 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
197197
// If we're operating on a standalone file (i.e. not in a folder) then we need
198198
// to launch the server in a reasonable current directory. Otherwise the cradle
199199
// guessing logic in hie-bios will be wrong!
200+
if (folder) {
201+
logger.info(`Activating the language server in the workspace folder: ${folder?.uri.fsPath}`);
202+
} else {
203+
logger.info(`Activating the language server in the parent dir of the file: ${uri.fsPath}`);
204+
}
205+
200206
const exeOptions: ExecutableOptions = {
201207
cwd: folder ? undefined : path.dirname(uri.fsPath),
202208
};
@@ -210,9 +216,12 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
210216

211217
logger.info(`run command: ${serverExecutable} ${args.join(' ')}`);
212218
logger.info(`debug command: ${serverExecutable} ${args.join(' ')}`);
213-
logger.info(`server cwd: ${exeOptions.cwd}`);
219+
if (exeOptions.cwd) {
220+
logger.info(`server cwd: ${exeOptions.cwd}`);
221+
}
214222

215223
const pat = folder ? `${folder.uri.fsPath}/**/*` : '**/*';
224+
logger.info(`document selector patten: ${pat}`);
216225
const clientOptions: LanguageClientOptions = {
217226
// Use the document selector to only notify the LSP on files inside the folder
218227
// path for the specific workspace.
@@ -244,7 +253,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
244253
langClient.registerProposedFeatures();
245254

246255
// Finally start the client and add it to the list of clients.
247-
logger.info('Starting language client');
256+
logger.info('Starting language server');
248257
langClient.start();
249258
clients.set(clientsKey, langClient);
250259
}

0 commit comments

Comments
 (0)