chore: include full messages into pw:channel logs (#27488)
Currently, we pass an object to the logger and it seems to use default Node's `util.inspect()` which does not print properties at 3+ depth.
This commit is contained in:
parent
45fe42e896
commit
ae5610f5c1
|
|
@ -123,14 +123,16 @@ export class Connection extends EventEmitter {
|
||||||
const guid = object._guid;
|
const guid = object._guid;
|
||||||
const type = object._type;
|
const type = object._type;
|
||||||
const id = ++this._lastId;
|
const id = ++this._lastId;
|
||||||
const converted = { id, guid, method, params };
|
const message = { id, guid, method, params };
|
||||||
// Do not include metadata in debug logs to avoid noise.
|
if (debugLogger.isEnabled('channel:command')) {
|
||||||
debugLogger.log('channel:command', converted);
|
// Do not include metadata in debug logs to avoid noise.
|
||||||
|
debugLogger.log('channel:command', JSON.stringify(message));
|
||||||
|
}
|
||||||
const location = frames[0] ? { file: frames[0].file, line: frames[0].line, column: frames[0].column } : undefined;
|
const location = frames[0] ? { file: frames[0].file, line: frames[0].line, column: frames[0].column } : undefined;
|
||||||
const metadata: channels.Metadata = { wallTime, apiName, location, internal: !apiName };
|
const metadata: channels.Metadata = { wallTime, apiName, location, internal: !apiName };
|
||||||
if (this._tracingCount && frames && type !== 'LocalUtils')
|
if (this._tracingCount && frames && type !== 'LocalUtils')
|
||||||
this._localUtils?._channel.addStackToTracingNoReply({ callData: { stack: frames, id } }).catch(() => {});
|
this._localUtils?._channel.addStackToTracingNoReply({ callData: { stack: frames, id } }).catch(() => {});
|
||||||
this.onmessage({ ...converted, metadata });
|
this.onmessage({ ...message, metadata });
|
||||||
return await new Promise((resolve, reject) => this._callbacks.set(id, { resolve, reject, stackTrace, type, method }));
|
return await new Promise((resolve, reject) => this._callbacks.set(id, { resolve, reject, stackTrace, type, method }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +142,8 @@ export class Connection extends EventEmitter {
|
||||||
|
|
||||||
const { id, guid, method, params, result, error } = message as any;
|
const { id, guid, method, params, result, error } = message as any;
|
||||||
if (id) {
|
if (id) {
|
||||||
debugLogger.log('channel:response', message);
|
if (debugLogger.isEnabled('channel:response'))
|
||||||
|
debugLogger.log('channel:response', JSON.stringify(message));
|
||||||
const callback = this._callbacks.get(id);
|
const callback = this._callbacks.get(id);
|
||||||
if (!callback)
|
if (!callback)
|
||||||
throw new Error(`Cannot find command to respond: ${id}`);
|
throw new Error(`Cannot find command to respond: ${id}`);
|
||||||
|
|
@ -154,7 +157,8 @@ export class Connection extends EventEmitter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLogger.log('channel:event', message);
|
if (debugLogger.isEnabled('channel:event'))
|
||||||
|
debugLogger.log('channel:event', JSON.stringify(message));
|
||||||
if (method === '__create__') {
|
if (method === '__create__') {
|
||||||
this._createRemoteObject(guid, params.type, params.guid, params.initializer);
|
this._createRemoteObject(guid, params.type, params.guid, params.initializer);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue