X-Git-Url: https://git.josue.xyz/?p=VSoRC%2F.git;a=blobdiff_plain;f=node_modules%2Fxterm%2Fsrc%2Fcommon%2Fservices%2FLogService.ts;fp=node_modules%2Fxterm%2Fsrc%2Fcommon%2Fservices%2FLogService.ts;h=0000000000000000000000000000000000000000;hp=4f48d8fe6865c57a102485a7713de5cc80bd528f;hb=5e96dd57ddd883604e87f62bdddcb111c63a6e1a;hpb=acb5f682a2b75b972710cabd81658f63071324b0 diff --git a/node_modules/xterm/src/common/services/LogService.ts b/node_modules/xterm/src/common/services/LogService.ts deleted file mode 100644 index 4f48d8f..0000000 --- a/node_modules/xterm/src/common/services/LogService.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2019 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { ILogService, IOptionsService } from 'common/services/Services'; - -type LogType = (message?: any, ...optionalParams: any[]) => void; - -interface IConsole { - log: LogType; - error: LogType; - info: LogType; - trace: LogType; - warn: LogType; -} - -// console is available on both node.js and browser contexts but the common -// module doesn't depend on them so we need to explicitly declare it. -declare const console: IConsole; - - -export enum LogLevel { - DEBUG = 0, - INFO = 1, - WARN = 2, - ERROR = 3, - OFF = 4 -} - -const optionsKeyToLogLevel: { [key: string]: LogLevel } = { - debug: LogLevel.DEBUG, - info: LogLevel.INFO, - warn: LogLevel.WARN, - error: LogLevel.ERROR, - off: LogLevel.OFF -}; - -const LOG_PREFIX = 'xterm.js: '; - -export class LogService implements ILogService { - serviceBrand: any; - - private _logLevel!: LogLevel; - - constructor( - @IOptionsService private readonly _optionsService: IOptionsService - ) { - this._updateLogLevel(); - this._optionsService.onOptionChange(key => { - if (key === 'logLevel') { - this._updateLogLevel(); - } - }); - } - - private _updateLogLevel(): void { - this._logLevel = optionsKeyToLogLevel[this._optionsService.options.logLevel]; - } - - private _evalLazyOptionalParams(optionalParams: any[]): void { - for (let i = 0; i < optionalParams.length; i++) { - if (typeof optionalParams[i] === 'function') { - optionalParams[i] = optionalParams[i](); - } - } - } - - private _log(type: LogType, message: string, optionalParams: any[]): void { - this._evalLazyOptionalParams(optionalParams); - type.call(console, LOG_PREFIX + message, ...optionalParams); - } - - debug(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.DEBUG) { - this._log(console.log, message, optionalParams); - } - } - - info(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.INFO) { - this._log(console.info, message, optionalParams); - } - } - - warn(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.WARN) { - this._log(console.warn, message, optionalParams); - } - } - - error(message: string, ...optionalParams: any[]): void { - if (this._logLevel <= LogLevel.ERROR) { - this._log(console.error, message, optionalParams); - } - } -}