crawlee icon indicating copy to clipboard operation
crawlee copied to clipboard

Statistics does not use crawler log

Open rougsig opened this issue 1 year ago • 1 comments

Which package is this bug report for? If unsure which one to select, leave blank

@crawlee/core

Issue description

Here Statistics use defaultLog. If I pass custom logger for crawler, statistics will report with default. No way to pass another logger.

https://github.com/apify/crawlee/blob/master/packages/core/src/crawlers/statistics.ts#L102

Code sample

    this.crawler = new PlaywrightCrawler(
      {
        log: new Log({
          logger: new CrawleePino({pino: baseLogger.child({type: 'crawlee'})}),
        }),
      }
    )

Package version

crawlee 3.8.2

Node.js version

v20.11.0

Operating system

linux

Apify platform

  • [ ] Tick me if you encountered this issue on the Apify platform

I have tested this on the next release

No response

Other context

No response

rougsig avatar Apr 09 '24 22:04 rougsig

As a workaround you can do something like this:

const log = new Log({
  logger: new CrawleePino({pino: baseLogger.child({type: 'crawlee'})}),
})
this.crawler = new PlaywrightCrawler(
  {
    log: log,
  },
)
// @ts-expect-error we want to use our own logger
this.crawler.stats.log = log

rougsig avatar Apr 09 '24 22:04 rougsig