Apify Discord Mirror

Updated 2 weeks ago

Replace default logger

Hello, did anybody manage to completely replace the logs from Crawlee with console logs ?
If yes, can you please share your implementation ?
C
1 comment
you can extend the log class and write your own _log method

Plain Text
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LogLevel, Logger, LoggerOptions } from '@crawlee/playwright';

export class CustomLogger extends Logger {
  constructor(
    options: LoggerOptions,
  ) {
    super(options);
  }

  override _log(
    level: LogLevel,
    message: string,
    data?: any,
    exception?: unknown,
    opts?: Record<string, any>,
  ): void {

  }
}


then you can inject it into the global config

Plain Text
  log.setOptions({
    logger: new CustomLogger(log.getOptions()),
  });
Add a reply
Sign up and join the conversation on Discord