@crawlee/core 4.0.0-beta.165 → 4.0.0-beta.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/log.d.ts +8 -8
- package/log.js +42 -12
- package/package.json +6 -6
package/log.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CrawleeLogger, CrawleeLoggerOptions } from '@crawlee/types';
|
|
1
|
+
import type { CrawleeLogger, CrawleeLoggerOptions, LogOptions } from '@crawlee/types';
|
|
2
2
|
import type { LoggerOptions } from '@apify/log';
|
|
3
3
|
import log, { Log, Logger, LoggerJson, LoggerText, LogLevel } from '@apify/log';
|
|
4
|
-
export type { CrawleeLogger, CrawleeLoggerOptions };
|
|
4
|
+
export type { CrawleeLogger, CrawleeLoggerOptions, LogOptions };
|
|
5
5
|
/**
|
|
6
6
|
* Abstract base class for custom Crawlee logger implementations.
|
|
7
7
|
*
|
|
@@ -55,14 +55,14 @@ export declare abstract class BaseCrawleeLogger implements CrawleeLogger {
|
|
|
55
55
|
getOptions(): CrawleeLoggerOptions;
|
|
56
56
|
setOptions(options: Partial<CrawleeLoggerOptions>): void;
|
|
57
57
|
child(options: Partial<CrawleeLoggerOptions>): CrawleeLogger;
|
|
58
|
-
error(message: string, data?: Record<string, unknown
|
|
58
|
+
error(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
59
59
|
exception(exception: Error, message: string, data?: Record<string, unknown>): void;
|
|
60
|
-
softFail(message: string, data?: Record<string, unknown
|
|
61
|
-
warning(message: string, data?: Record<string, unknown
|
|
60
|
+
softFail(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
61
|
+
warning(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
62
62
|
warningOnce(message: string): void;
|
|
63
|
-
info(message: string, data?: Record<string, unknown
|
|
64
|
-
debug(message: string, data?: Record<string, unknown
|
|
65
|
-
perf(message: string, data?: Record<string, unknown
|
|
63
|
+
info(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
64
|
+
debug(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
65
|
+
perf(message: string, data?: Record<string, unknown>, options?: LogOptions): void;
|
|
66
66
|
deprecated(message: string): void;
|
|
67
67
|
}
|
|
68
68
|
/**
|
package/log.js
CHANGED
|
@@ -33,7 +33,7 @@ export class BaseCrawleeLogger {
|
|
|
33
33
|
// Note: If wrapping logger in a Proxy, unbound methods calling #-fields throw TypeError
|
|
34
34
|
// unless bound to the target (see createLogProxy in adaptive-playwright-crawler.ts).
|
|
35
35
|
#options;
|
|
36
|
-
#
|
|
36
|
+
#loggedOnce = new Set();
|
|
37
37
|
constructor(options = {}) {
|
|
38
38
|
this.#options = options;
|
|
39
39
|
}
|
|
@@ -46,7 +46,27 @@ export class BaseCrawleeLogger {
|
|
|
46
46
|
child(options) {
|
|
47
47
|
return this.createChild(options);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Whether `once` suppresses this message. Keyed by level as well as text, so that a message logged once as
|
|
51
|
+
* `info` does not swallow the same text logged as a `warning`.
|
|
52
|
+
*
|
|
53
|
+
* Handled here rather than in {@link BaseCrawleeLogger.logWithLevel} so that every logger gets it, instead
|
|
54
|
+
* of each implementation having to dedupe for itself.
|
|
55
|
+
*/
|
|
56
|
+
#suppressedAsRepeat(level, message, options) {
|
|
57
|
+
if (!options?.once) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const key = `${level}:${message}`;
|
|
61
|
+
if (this.#loggedOnce.has(key)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
this.#loggedOnce.add(key);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
error(message, data, options) {
|
|
68
|
+
if (this.#suppressedAsRepeat(LogLevel.ERROR, message, options))
|
|
69
|
+
return;
|
|
50
70
|
this.logWithLevel(LogLevel.ERROR, message, data);
|
|
51
71
|
}
|
|
52
72
|
exception(exception, message, data) {
|
|
@@ -56,25 +76,35 @@ export class BaseCrawleeLogger {
|
|
|
56
76
|
exception,
|
|
57
77
|
});
|
|
58
78
|
}
|
|
59
|
-
softFail(message, data) {
|
|
79
|
+
softFail(message, data, options) {
|
|
80
|
+
if (this.#suppressedAsRepeat(LogLevel.SOFT_FAIL, message, options))
|
|
81
|
+
return;
|
|
60
82
|
this.logWithLevel(LogLevel.SOFT_FAIL, message, data);
|
|
61
83
|
}
|
|
62
|
-
warning(message, data) {
|
|
84
|
+
warning(message, data, options) {
|
|
85
|
+
if (this.#suppressedAsRepeat(LogLevel.WARNING, message, options))
|
|
86
|
+
return;
|
|
63
87
|
this.logWithLevel(LogLevel.WARNING, message, data);
|
|
64
88
|
}
|
|
65
89
|
warningOnce(message) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
info(message, data) {
|
|
90
|
+
// Gates before delegating, so that a suppressed repeat is not even a `warning()` call.
|
|
91
|
+
if (this.#suppressedAsRepeat(LogLevel.WARNING, message, { once: true }))
|
|
92
|
+
return;
|
|
93
|
+
this.warning(message);
|
|
94
|
+
}
|
|
95
|
+
info(message, data, options) {
|
|
96
|
+
if (this.#suppressedAsRepeat(LogLevel.INFO, message, options))
|
|
97
|
+
return;
|
|
72
98
|
this.logWithLevel(LogLevel.INFO, message, data);
|
|
73
99
|
}
|
|
74
|
-
debug(message, data) {
|
|
100
|
+
debug(message, data, options) {
|
|
101
|
+
if (this.#suppressedAsRepeat(LogLevel.DEBUG, message, options))
|
|
102
|
+
return;
|
|
75
103
|
this.logWithLevel(LogLevel.DEBUG, message, data);
|
|
76
104
|
}
|
|
77
|
-
perf(message, data) {
|
|
105
|
+
perf(message, data, options) {
|
|
106
|
+
if (this.#suppressedAsRepeat(LogLevel.PERF, message, options))
|
|
107
|
+
return;
|
|
78
108
|
this.logWithLevel(LogLevel.PERF, `[PERF] ${message}`, data);
|
|
79
109
|
}
|
|
80
110
|
deprecated(message) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/core",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.166",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"@apify/log": "^3.0.1",
|
|
53
53
|
"@apify/timeout": "^1.0.1",
|
|
54
54
|
"@apify/utilities": "^3.0.1",
|
|
55
|
-
"@crawlee/fs-storage": "4.0.0-beta.
|
|
56
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
57
|
-
"@crawlee/types": "4.0.0-beta.
|
|
58
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
55
|
+
"@crawlee/fs-storage": "4.0.0-beta.166",
|
|
56
|
+
"@crawlee/http-client": "4.0.0-beta.166",
|
|
57
|
+
"@crawlee/types": "4.0.0-beta.166",
|
|
58
|
+
"@crawlee/utils": "4.0.0-beta.166",
|
|
59
59
|
"@sapphire/async-queue": "^1.5.5",
|
|
60
60
|
"@standard-schema/spec": "^1.0.0",
|
|
61
61
|
"@vladfrangu/async_event_emitter": "^2.4.6",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "5d34cf3b9da170f22cf5b346014ba44060dad827"
|
|
82
82
|
}
|