import * as spdlog from "spdlog"; import { ClientProxy } from "../../common/proxy"; import { RotatingLoggerProxy, SpdlogModuleProxy } from "../../node/modules/spdlog"; class RotatingLogger extends ClientProxy implements spdlog.RotatingLogger { public constructor( private readonly moduleProxy: SpdlogModuleProxy, private readonly name: string, private readonly filename: string, private readonly filesize: number, private readonly filecount: number, ) { super(moduleProxy.createLogger(name, filename, filesize, filecount)); } public async trace (message: string): Promise { this.proxy.trace(message); } public async debug (message: string): Promise { this.proxy.debug(message); } public async info (message: string): Promise { this.proxy.info(message); } public async warn (message: string): Promise { this.proxy.warn(message); } public async error (message: string): Promise { this.proxy.error(message); } public async critical (message: string): Promise { this.proxy.critical(message); } public async setLevel (level: number): Promise { this.proxy.setLevel(level); } public async clearFormatters (): Promise { this.proxy.clearFormatters(); } public async flush (): Promise { this.proxy.flush(); } public async drop (): Promise { this.proxy.drop(); } protected handleDisconnect(): void { this.initialize(this.moduleProxy.createLogger(this.name, this.filename, this.filesize, this.filecount)); } } export class SpdlogModule { public readonly RotatingLogger: typeof spdlog.RotatingLogger; public constructor(private readonly proxy: SpdlogModuleProxy) { this.RotatingLogger = class extends RotatingLogger { public constructor(name: string, filename: string, filesize: number, filecount: number) { super(proxy, name, filename, filesize, filecount); } }; } public setAsyncMode = (bufferSize: number, flushInterval: number): void => { this.proxy.setAsyncMode(bufferSize, flushInterval); } }