ContextLogger
@tsed/di
Usage
typescript
import { ContextLogger } from "@tsed/di";
Overview
ts
class ContextLogger {
readonly dateStart: Date;
readonly id: string;
maxStackSize: number;
level: LogLevel;
constructor({ id, logger, dateStart, level, maxStackSize, additionalProps }: ContextLoggerOptions);
get hooks(): Hooks;
alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "all", withRequest: boolean) => any): Hooks;
alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean): Hooks;
info(obj: any): this;
debug(obj: any): this;
warn(obj: any): this;
error(obj: any): this;
fatal(obj: any): this;
trace(obj: any): this;
flush(stream?: boolean): void;
isLevelEnabled(otherLevel: string | LogLevel): boolean;
protected getDuration(): number;
protected getData(obj: any): any;
protected run(level: LogLevel, obj: any, withRequest?: boolean): void;
}
readonly dateStart
ts
readonly dateStart: Date;
readonly id
ts
readonly id: string;
maxStackSize
ts
maxStackSize: number;
level
ts
level: LogLevel;
get hooks
ts
get hooks(): Hooks;
alterLog
ts
alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "all", withRequest: boolean) => any): Hooks;
alterIgnoreLog
ts
alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean): Hooks;
info
ts
info(obj: any): this;
debug
ts
debug(obj: any): this;
warn
ts
warn(obj: any): this;
error
ts
error(obj: any): this;
fatal
ts
fatal(obj: any): this;
trace
ts
trace(obj: any): this;
flush
ts
flush(stream?: boolean): void;
isLevelEnabled
ts
isLevelEnabled(otherLevel: string | LogLevel): boolean;
protected getDuration
ts
protected getDuration(): number;
Return the duration between the time when LogIncomingRequest has handle the request and now.
protected getData
ts
protected getData(obj: any): any;
protected run
ts
protected run(level: LogLevel, obj: any, withRequest?: boolean): void;