@@ -57,30 +57,30 @@ export class LogService extends Disposable implements ILogService {
|
|||||||
|
|
||||||
private _log(type: LogType, message: string, optionalParams: any[]): void {
|
private _log(type: LogType, message: string, optionalParams: any[]): void {
|
||||||
this._evalLazyOptionalParams(optionalParams);
|
this._evalLazyOptionalParams(optionalParams);
|
||||||
type.call(console, LOG_PREFIX + message, ...optionalParams);
|
type.call(console, (this._optionsService.options.logger ? '' : LOG_PREFIX) + message, ...optionalParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public debug(message: string, ...optionalParams: any[]): void {
|
public debug(message: string, ...optionalParams: any[]): void {
|
||||||
if (this.logLevel <= LogLevelEnum.DEBUG) {
|
if (this.logLevel <= LogLevelEnum.DEBUG) {
|
||||||
this._log(console.log, message, optionalParams);
|
this._log(this._optionsService.options.logger?.debug ?? console.log, message, optionalParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public info(message: string, ...optionalParams: any[]): void {
|
public info(message: string, ...optionalParams: any[]): void {
|
||||||
if (this.logLevel <= LogLevelEnum.INFO) {
|
if (this.logLevel <= LogLevelEnum.INFO) {
|
||||||
this._log(console.info, message, optionalParams);
|
this._log(this._optionsService.options.logger?.info ?? console.info, message, optionalParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public warn(message: string, ...optionalParams: any[]): void {
|
public warn(message: string, ...optionalParams: any[]): void {
|
||||||
if (this.logLevel <= LogLevelEnum.WARN) {
|
if (this.logLevel <= LogLevelEnum.WARN) {
|
||||||
this._log(console.warn, message, optionalParams);
|
this._log(this._optionsService.options.logger?.warn ?? console.warn, message, optionalParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public error(message: string, ...optionalParams: any[]): void {
|
public error(message: string, ...optionalParams: any[]): void {
|
||||||
if (this.logLevel <= LogLevelEnum.ERROR) {
|
if (this.logLevel <= LogLevelEnum.ERROR) {
|
||||||
this._log(console.error, message, optionalParams);
|
this._log(this._optionsService.options.logger?.error ?? console.error, message, optionalParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|||||||
letterSpacing: 0,
|
letterSpacing: 0,
|
||||||
linkHandler: null,
|
linkHandler: null,
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
|
logger: null,
|
||||||
scrollback: 1000,
|
scrollback: 1000,
|
||||||
scrollOnUserInput: true,
|
scrollOnUserInput: true,
|
||||||
scrollSensitivity: 1,
|
scrollSensitivity: 1,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
|||||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, IOscLinkData } from 'common/Types';
|
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, IOscLinkData } from 'common/Types';
|
||||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||||
import { IDecorationOptions, IDecoration, ILinkHandler, IWindowsPty } from 'xterm';
|
import { IDecorationOptions, IDecoration, ILinkHandler, IWindowsPty, ILogger } from 'xterm';
|
||||||
|
|
||||||
export const IBufferService = createDecorator<IBufferService>('BufferService');
|
export const IBufferService = createDecorator<IBufferService>('BufferService');
|
||||||
export interface IBufferService {
|
export interface IBufferService {
|
||||||
@@ -229,6 +229,7 @@ export interface ITerminalOptions {
|
|||||||
lineHeight?: number;
|
lineHeight?: number;
|
||||||
linkHandler?: ILinkHandler | null;
|
linkHandler?: ILinkHandler | null;
|
||||||
logLevel?: LogLevel;
|
logLevel?: LogLevel;
|
||||||
|
logger?: ILogger | null;
|
||||||
macOptionIsMeta?: boolean;
|
macOptionIsMeta?: boolean;
|
||||||
macOptionClickForcesSelection?: boolean;
|
macOptionClickForcesSelection?: boolean;
|
||||||
minimumContrastRatio?: number;
|
minimumContrastRatio?: number;
|
||||||
|
|||||||
Vendored
+31
@@ -107,6 +107,11 @@ declare module 'xterm-headless' {
|
|||||||
*/
|
*/
|
||||||
logLevel?: LogLevel;
|
logLevel?: LogLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A logger to use instead of `console`.
|
||||||
|
*/
|
||||||
|
logger?: ILogger | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to treat option as the meta key.
|
* Whether to treat option as the meta key.
|
||||||
*/
|
*/
|
||||||
@@ -304,6 +309,32 @@ declare module 'xterm-headless' {
|
|||||||
buildNumber?: number;
|
buildNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A replacement logger for `console`.
|
||||||
|
*/
|
||||||
|
export interface ILogger {
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* debug.
|
||||||
|
*/
|
||||||
|
debug(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* info or below.
|
||||||
|
*/
|
||||||
|
info(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* warn or below.
|
||||||
|
*/
|
||||||
|
warn(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* error or below.
|
||||||
|
*/
|
||||||
|
error(message: string | Error, ...args: any[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that can be disposed via a dispose function.
|
* An object that can be disposed via a dispose function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+31
@@ -152,6 +152,11 @@ declare module 'xterm' {
|
|||||||
*/
|
*/
|
||||||
logLevel?: LogLevel;
|
logLevel?: LogLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A logger to use instead of `console`.
|
||||||
|
*/
|
||||||
|
logger?: ILogger | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to treat option as the meta key.
|
* Whether to treat option as the meta key.
|
||||||
*/
|
*/
|
||||||
@@ -365,6 +370,32 @@ declare module 'xterm' {
|
|||||||
buildNumber?: number;
|
buildNumber?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A replacement logger for `console`.
|
||||||
|
*/
|
||||||
|
export interface ILogger {
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* debug.
|
||||||
|
*/
|
||||||
|
debug(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* info or below.
|
||||||
|
*/
|
||||||
|
info(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* warn or below.
|
||||||
|
*/
|
||||||
|
warn(message: string, ...args: any[]): void;
|
||||||
|
/**
|
||||||
|
* Log a debug message, this will only be called if {@link ITerminalOptions.logLevel} is set to
|
||||||
|
* error or below.
|
||||||
|
*/
|
||||||
|
error(message: string | Error, ...args: any[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that can be disposed via a dispose function.
|
* An object that can be disposed via a dispose function.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user