Skip to content

Commit 3f75b88

Browse files
authored
Emit logs on sterr stream (#459)
1 parent 68a7a48 commit 3f75b88

File tree

4 files changed

+6
-21
lines changed

4 files changed

+6
-21
lines changed

src/app/initialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { toString } from '../utils/String';
1010
export function staticInitialize(ClientInfo?: ClientInfo, AwsMetadata?: AwsMetadata) {
1111
if (!isTest) {
1212
// eslint-disable-next-line no-console
13-
console.info(
13+
console.error(
1414
toString({
1515
Service: Service,
1616
Environment: ServiceEnv,

src/app/standalone.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { InitializedParams } from 'vscode-languageserver-protocol';
33
import { LspCapabilities } from '../protocol/LspCapabilities';
44
import { LspConnection } from '../protocol/LspConnection';
55
import { ExtendedInitializeParams } from '../server/InitParams';
6-
import { LoggerFactory } from '../telemetry/LoggerFactory';
76
import { ExtensionName } from '../utils/ExtensionConfig';
87
import { staticInitialize } from './initialize';
98

@@ -24,16 +23,16 @@ async function onInitialize(params: ExtendedInitializeParams) {
2423

2524
function onInitialized(params: InitializedParams) {
2625
(server as any).initialized(params);
27-
getLogger().info(`${ExtensionName} initialized`);
26+
console.error(`${ExtensionName} initialized`);
2827
}
2928

3029
function onShutdown() {
31-
console.info(`${ExtensionName} shutting down...`);
30+
console.error(`${ExtensionName} shutting down...`);
3231
return (server as any).close();
3332
}
3433

3534
function onExit() {
36-
console.info(`${ExtensionName} exiting`);
35+
console.error(`${ExtensionName} exiting`);
3736
}
3837

3938
const lsp = new LspConnection(createConnection(ProposedFeatures.all), {
@@ -46,23 +45,8 @@ lsp.listen();
4645

4746
process.on('unhandledRejection', (reason, _promise) => {
4847
console.error(reason, 'Unhandled promise rejection');
49-
50-
try {
51-
getLogger().error(reason, 'Unhandled promise rejection');
52-
} catch {
53-
// do nothing
54-
}
5548
});
5649

5750
process.on('uncaughtException', (error, origin) => {
5851
console.error(error, `Unhandled exception ${origin}`);
59-
try {
60-
getLogger().error(error, `Uncaught exception ${origin}`);
61-
} catch {
62-
// do nothing
63-
}
6452
});
65-
66-
function getLogger() {
67-
return LoggerFactory.getLogger('Init');
68-
}

src/telemetry/LoggerFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class LoggerFactory implements Closeable {
3737
{
3838
target: 'pino-pretty',
3939
options: {
40+
destination: 2, // stderr — stdout is reserved for LSP JSON-RPC in --stdio mode
4041
colorize: false,
4142
translateTime: 'SYS:hh:MM:ss TT',
4243
ignore: 'pid,hostname,name,clazz',

src/utils/Storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Storage {
3333
static initialize(storageDir?: string): void {
3434
this.root = storageDir ?? this.getDefaultStorageRoot();
3535
if (!isTest) {
36-
console.info(`Initializing storage at ${this.root}`); // eslint-disable-line no-console
36+
console.error(`Initializing storage at ${this.root}`); // eslint-disable-line no-console
3737
}
3838
this.cleanupLegacyStorage();
3939
}

0 commit comments

Comments
 (0)