-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Support LogOutputChannel - Support LogLevel - Support in namespace/env: logLevel & onDidChangeLogLevel - Remark: Needs further extension of application to fully support all aspects of a LogOutputViewChannel (i.e. developer logger service, logging to file, extension of output view UI) Resolves #12017 Contributed on behalf of STMicroelectronics. Signed-off-by: Nina Doschek <ndoschek@eclipsesource.com>
- Loading branch information
Showing
9 changed files
with
245 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/plugin-ext/src/plugin/output-channel/logoutput-channel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { AbstractMessageLogger, DEFAULT_LOG_LEVEL, LogLevel } from '@theia/monaco-editor-core/esm/vs/platform/log/common/log'; | ||
import * as theia from '@theia/plugin'; | ||
|
||
import { OutputChannelRegistryMain, PluginInfo } from '../../common/plugin-api-rpc'; | ||
import { toLogLevel } from '../type-converters'; | ||
|
||
export class LogOutputChannelImpl extends AbstractMessageLogger implements theia.LogOutputChannel { | ||
|
||
private _disposed: boolean = false; | ||
get disposed(): boolean { return this._disposed; } | ||
|
||
override onDidChangeLogLevel: theia.Event<theia.LogLevel>; | ||
|
||
constructor(readonly name: string, protected proxy: OutputChannelRegistryMain, protected readonly pluginInfo: PluginInfo) { | ||
super(); | ||
this.setLevel(DEFAULT_LOG_LEVEL); | ||
} | ||
|
||
get logLevel(): theia.LogLevel { | ||
return toLogLevel(this.getLevel()); | ||
} | ||
|
||
append(value: string): void { | ||
this.info(value); | ||
} | ||
|
||
appendLine(value: string): void { | ||
this.append(value + '\n'); | ||
} | ||
|
||
replace(value: string): void { | ||
this.info(value); | ||
this.proxy.$append(this.name, value, this.pluginInfo); | ||
} | ||
|
||
clear(): void { | ||
this.proxy.$clear(this.name); | ||
} | ||
|
||
show(columnOrPreserveFocus?: theia.ViewColumn | boolean, preserveFocus?: boolean): void { | ||
this.proxy.$reveal(this.name, !!(typeof columnOrPreserveFocus === 'boolean' ? columnOrPreserveFocus : preserveFocus)); | ||
} | ||
|
||
hide(): void { | ||
this.proxy.$close(this.name); | ||
} | ||
|
||
protected log(level: LogLevel, message: string): void { | ||
const now = new Date(Date.now()); | ||
const eol = message.endsWith('\n') ? '' : '\n'; | ||
const logMessage = `${now.toISOString()} [${LogLevel[level]}] ${message}${eol}`; | ||
this.proxy.$append(this.name, logMessage, this.pluginInfo); | ||
} | ||
|
||
override dispose(): void { | ||
super.dispose(); | ||
|
||
if (!this._disposed) { | ||
this.proxy.$dispose(this.name); | ||
this._disposed = true; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters