Skip to content

Commit 28a38eb

Browse files
committed
🔊 replace ts with invocation ID for pup logs #2452
1 parent ccc3789 commit 28a38eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/Client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ export class Client {
507507

508508

509509
private async pup(pageFunction:EvaluateFn<any>, ...args) {
510+
const invocation_id = uuidv4().slice(-5);
510511
const {safeMode, callTimeout, idCorrection, logging} = this._createConfig;
511512
let _t : number;
512513
if(safeMode) {
@@ -539,15 +540,15 @@ export class Client {
539540
if(logging) {
540541
const wapis = (pageFunction?.toString()?.match(/WAPI\.(\w*)\(/g) || [])?.map(s=>s.replace(/WAPI|\.|\(/g,''));
541542
_t = Date.now()
542-
log.info(`Request ${_t}`,{
543+
log.info(`Request ${invocation_id}`,{
543544
_method: wapis?.length === 1 ? wapis[0] : wapis,
544545
...args[0]
545546
})
546547
}
547548
if(callTimeout) return await Promise.race([this._page.evaluate(pageFunction, ...args),new Promise((resolve, reject) => setTimeout(reject, this._createConfig?.callTimeout, new PageEvaluationTimeout()))])
548549
const res = await this._page.evaluate(pageFunction, ...args);
549550
if(_t && logging) {
550-
log.info(`Response ${_t}: ${Date.now() - _t}ms`, {res})
551+
log.info(`Response ${invocation_id}: ${Date.now() - _t}ms`, {res})
551552
}
552553
if(this._createConfig.onError && typeof res == "string" && (res.startsWith("Error") || res.startsWith("ERROR"))) {
553554
const e = this._createConfig.onError;

0 commit comments

Comments
 (0)