Comparing version 5.3.0-beta.44 to 5.3.0-beta.45
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "5.3.0-beta.44", | ||
"version": "5.3.0-beta.45", | ||
"main": "lib/xterm.js", | ||
@@ -6,0 +6,0 @@ "style": "css/xterm.css", |
@@ -19,2 +19,3 @@ /** | ||
import { IColorContrastCache } from 'browser/Types'; | ||
import { traceCall } from 'common/services/LogService'; | ||
@@ -429,2 +430,3 @@ /** | ||
@traceCall | ||
private _drawToCache(codeOrChars: number | string, bg: number, fg: number, ext: number, restrictToCellHeight: boolean = false): IRasterizedGlyph { | ||
@@ -431,0 +433,0 @@ const chars = typeof codeOrChars === 'number' ? String.fromCharCode(codeOrChars) : codeOrChars; |
@@ -24,2 +24,3 @@ /** | ||
const optionsKeyToLogLevel: { [key: string]: LogLevelEnum } = { | ||
trace: LogLevelEnum.TRACE, | ||
debug: LogLevelEnum.DEBUG, | ||
@@ -46,2 +47,5 @@ info: LogLevelEnum.INFO, | ||
this.register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel())); | ||
// For trace logging, assume the latest created log service is valid | ||
traceLogger = this; | ||
} | ||
@@ -66,2 +70,8 @@ | ||
public trace(message: string, ...optionalParams: any[]): void { | ||
if (this._logLevel <= LogLevelEnum.TRACE) { | ||
this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger) ?? console.log, message, optionalParams); | ||
} | ||
} | ||
public debug(message: string, ...optionalParams: any[]): void { | ||
@@ -91,1 +101,28 @@ if (this._logLevel <= LogLevelEnum.DEBUG) { | ||
} | ||
let traceLogger: ILogService; | ||
export function setTraceLogger(logger: ILogService): void { | ||
traceLogger = logger; | ||
} | ||
/** | ||
* A decorator that can be used to automatically log trace calls to the decorated function. | ||
*/ | ||
export function traceCall(_target: any, key: string, descriptor: any): any { | ||
if (typeof descriptor.value !== 'function') { | ||
throw new Error('not supported'); | ||
} | ||
const fnKey = 'value'; | ||
const fn = descriptor.value; | ||
descriptor[fnKey] = function (...args: any[]) { | ||
// Early exit | ||
if (traceLogger.logLevel !== LogLevelEnum.TRACE) { | ||
return fn.apply(this, args); | ||
} | ||
traceLogger.trace(`GlyphRenderer#${fn.name}(${args.map(e => JSON.stringify(e)).join(', ')})`); | ||
const result = fn.apply(this, args); | ||
traceLogger.trace(`GlyphRenderer#${fn.name} return`, result); | ||
return result; | ||
}; | ||
} |
@@ -145,7 +145,8 @@ /** | ||
export enum LogLevelEnum { | ||
DEBUG = 0, | ||
INFO = 1, | ||
WARN = 2, | ||
ERROR = 3, | ||
OFF = 4 | ||
TRACE = 0, | ||
DEBUG = 1, | ||
INFO = 2, | ||
WARN = 3, | ||
ERROR = 4, | ||
OFF = 5 | ||
} | ||
@@ -159,2 +160,3 @@ | ||
trace(message: any, ...optionalParams: any[]): void; | ||
debug(message: any, ...optionalParams: any[]): void; | ||
@@ -206,3 +208,3 @@ info(message: any, ...optionalParams: any[]): void; | ||
export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number; | ||
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; | ||
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'off'; | ||
@@ -209,0 +211,0 @@ export interface ITerminalOptions { |
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'; | ||
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'off'; | ||
@@ -162,7 +162,8 @@ /** | ||
* | ||
* 1. debug | ||
* 2. info (default) | ||
* 3. warn | ||
* 4. error | ||
* 5. off | ||
* 1. trace | ||
* 2. debug | ||
* 3. info (default) | ||
* 4. warn | ||
* 5. error | ||
* 6. off | ||
*/ | ||
@@ -397,4 +398,9 @@ logLevel?: LogLevel; | ||
/** | ||
* Log a trace message, this will only be called if | ||
* {@link ITerminalOptions.logLevel} is set to trace. | ||
*/ | ||
trace(message: string, ...args: any[]): void; | ||
/** | ||
* Log a debug message, this will only be called if | ||
* {@link ITerminalOptions.logLevel} is set to debug. | ||
* {@link ITerminalOptions.logLevel} is set to debug or below. | ||
*/ | ||
@@ -401,0 +407,0 @@ debug(message: string, ...args: any[]): void; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2341737
24404