|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import { Disposable } from 'vs/base/common/lifecycle'; |
| 7 | +import { Event } from 'vs/base/common/event'; |
| 8 | +import { localize } from 'vs/nls'; |
| 9 | +import { ILogger, ILoggerService, LogLevel } from 'vs/platform/log/common/log'; |
| 10 | +import { ITerminalLogService } from 'vs/platform/terminal/common/terminal'; |
| 11 | + |
| 12 | +export class TerminalLogService extends Disposable implements ITerminalLogService { |
| 13 | + declare _serviceBrand: undefined; |
| 14 | + |
| 15 | + private readonly _logger: ILogger; |
| 16 | + |
| 17 | + get onDidChangeLogLevel(): Event<LogLevel> { return this._logger.onDidChangeLogLevel; } |
| 18 | + |
| 19 | + constructor(@ILoggerService private readonly _loggerService: ILoggerService) { |
| 20 | + super(); |
| 21 | + this._logger = this._loggerService.createLogger('terminal', { name: localize('terminalLoggerName', 'Terminal') }); |
| 22 | + } |
| 23 | + |
| 24 | + getLevel(): LogLevel { return this._logger.getLevel(); } |
| 25 | + setLevel(level: LogLevel): void { this._logger.setLevel(level); } |
| 26 | + trace(message: string, ...args: any[]): void { this.trace(message, args); } |
| 27 | + debug(message: string, ...args: any[]): void { this.debug(message, args); } |
| 28 | + info(message: string, ...args: any[]): void { this.info(message, args); } |
| 29 | + warn(message: string, ...args: any[]): void { this.warn(message, args); } |
| 30 | + error(message: string | Error, ...args: any[]): void { this.error(message, args); } |
| 31 | + flush(): void { this._logger.flush(); } |
| 32 | +} |
0 commit comments