Skip to content

Commit f74d473

Browse files
authored
Read log level from output channel (#1632)
1 parent 9346b41 commit f74d473

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

client/src/common/client.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
644644
private _outputChannel: LogOutputChannel | undefined;
645645
private _disposeOutputChannel: boolean;
646646
private _traceOutputChannel: LogOutputChannel | undefined;
647-
private _logLevel: LogLevel;
647+
private _traceLogLevel: LogLevel;
648648
private _capabilities!: ServerCapabilities & ResolvedTextDocumentSyncCapabilities;
649649

650650
private _diagnostics: DiagnosticCollection | undefined;
@@ -736,12 +736,16 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
736736
if (clientOptions.outputChannel) {
737737
this._outputChannel = clientOptions.outputChannel;
738738
this._disposeOutputChannel = false;
739+
this._traceLogLevel = this._outputChannel.logLevel;
739740
} else {
740741
this._outputChannel = undefined;
741742
this._disposeOutputChannel = true;
743+
this._traceLogLevel = LogLevel.Info;
742744
}
743745
this._traceOutputChannel = clientOptions.traceOutputChannel;
744-
this._logLevel = LogLevel.Info;
746+
if (this._traceOutputChannel !== undefined) {
747+
this._traceLogLevel = this._traceOutputChannel.logLevel;
748+
}
745749
this._diagnostics = undefined;
746750

747751
this._inFlightOpenNotifications = new Set();
@@ -821,6 +825,9 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
821825
public get outputChannel(): LogOutputChannel {
822826
if (!this._outputChannel) {
823827
this._outputChannel = Window.createOutputChannel(this._clientOptions.outputChannelName ? this._clientOptions.outputChannelName : this._name, { log: true });
828+
if (this._traceOutputChannel === undefined) {
829+
this._traceLogLevel = this._outputChannel.logLevel;
830+
}
824831
}
825832
return this._outputChannel;
826833
}
@@ -1835,14 +1842,14 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
18351842

18361843
private hookLogLevelChanged(connection: Connection): void {
18371844
this._listeners.push(this.traceOutputChannel.onDidChangeLogLevel((level) => {
1838-
this._logLevel = level;
1845+
this._traceLogLevel = level;
18391846
this.refreshTrace(connection, true);
18401847
}));
18411848
}
18421849

18431850
private refreshTrace(connection: Connection, sendNotification: boolean = false): void {
18441851
const config = Workspace.getConfiguration(this._id);
1845-
let trace: Trace = this._logLevel !== LogLevel.Trace ? Trace.Off : Trace.Messages;
1852+
let trace: Trace = this._traceLogLevel !== LogLevel.Trace ? Trace.Off : Trace.Messages;
18461853
let traceFormat: TraceFormat = TraceFormat.Text;
18471854
if (config && trace !== Trace.Off) {
18481855
const traceConfig = config.get('trace.server', 'messages');

0 commit comments

Comments
 (0)