Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
fix: expose logger classes on the `utils.log` instance (#1278)
Martin Adámeke622e6b62ca8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 32f08943f..6d5b9fbbb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,6 +4,7 @@- fix: do not use `tryCancel()` from inside sync callback (#1265)- fix: revert to puppeteer 10.x- fix: wait when `body` is not available in `infiniteScroll()` from Puppeteer utils+- fix: expose logger classes on the `utils.log` instance2.2.0 / 2021/12/17====================diff --git a/src/utils_log.js b/src/utils_log.jsindex 21dce779f..bf6cc474b 100644--- a/src/utils_log.js+++ b/src/utils_log.js@@ -192,5 +192,8 @@// variable can't be the same from the namespace aboveimport log, { Log, LoggerOptions, LogLevel, Logger, LoggerJson, LoggerText } from '@apify/log';+// workaround for 2.x, this should ideally not be backported to 3.0 (the test should be there tho)+Object.assign(log, { Log, LogLevel, Logger, LoggerJson, LoggerText });+export { Log, LoggerOptions, LogLevel, Logger, LoggerJson, LoggerText };export default log;diff --git a/test/utils.test.js b/test/utils.test.jsindex 0ddded45a..76b173248 100644--- a/test/utils.test.js+++ b/test/utils.test.js@@ -8,6 +8,7 @@ import cheerio from 'cheerio';import semver from 'semver';import { ENV_VARS } from '@apify/consts';import { addTimeoutToPromise } from '@apify/timeout';+import { Log, LoggerText } from '@apify/log';import Apify from '../build/index';import * as utils from '../build/utils';import log from '../build/utils_log';@@ -35,6 +36,13 @@ describe('utils.newClient()', () => {});});+describe('log export exposes custom loggers', () => {+ test('works with log.LoggerText (#1238)', () => {+ expect(Apify.utils.log).toBeInstanceOf(Log);+ expect(Apify.utils.log.LoggerText).toBe(LoggerText);+ });+});+describe('utils.addCharsetToContentType()', () => {test('works', () => {expect(utils.addCharsetToContentType('application/json; charset=something')).toBe('application/json; charset=something');