Open thoroc opened 8 months ago
Yes I am aware this is using chalk
to get some colors in.
same issue
the mini reproduct is :
export class CustomLoggerGenerator<LogObj extends any> extends Logger<LogObj> {
public customLog(...args: unknown[]): LogObj & ILogObjMeta | undefined {
return this.log(3, 'LOG', ...args);
}
}
// then create it
const lg = new CustomLoggerGenerator();
lg.customLog('log it');
Describe the bug I would expect the custom log level implemented as per documentation to report on the file where the call was made instead of the file where the custom logger lives.
To Reproduce Steps to reproduce the behavior:
export interface ActionProps { action: string; message: string; resources?: string[]; }
export class CustomLogger extends Logger {
constructor(settings?: ISettingsParam, logObj?: LogObj) {
super(settings, logObj);
}
public action(...args: unknown[]): (LogObj & ILogObjMeta) | undefined { args = args.map((arg) => { if (typeof arg === 'object') { const { action, message, resources } = arg as ActionProps; let msg =
${chalk.green(action)} ${message}
;}
public custom(...args: unknown[]): (LogObj & ILogObjMeta) | undefined { return super.log(8, 'CUSTOM', ...args); } }
export const log = new CustomLogger();
Expected behavior the first two calls should have been reported being made in
generator.ts
in line 33 and 34 but instead were reported to have been made inlogger.ts
Screenshots
Additional context Add any other context about the problem here.
Node.js Version v20.11.0
OS incl. Version MacOS: 14.3.1 (23D60)
Shell Zshell with oh-my-zshell