Summary
The SDK writes directly to console.log / console.warn from several internal code paths. When embedded in a Node service that uses a structured logger (pino, winston, etc.), these unstructured lines pollute stdout and break log ingestion. There's currently no way to disable them without monkey-patching console.
Example output per attestation
sendTransaction params: submitTask 0x52ca... 1 0 0x0000... { value: BigNumber {...}, ... }
findFastestWs [ '...phala.network' ]
testSpeed done [ '...phala.network' ]
----------Attest algorithm duration: 30514
attestationList from algorithm [ { attestation: {...}, signature: '0x...', ... } ]
The attestationList line is particularly heavy since it includes the full signed attestation on every call.
A few of the call sites (there are more): src/index.ts#L391, src/classes/Contract.ts#L43, src/utils.ts#L158.
Proposed fix
Option 1: silent flag
Add a silent option on the constructor:
const primus = new PrimusZKTLS({ silent: true });
- Defaults to
false, so current behavior is preserved.
- When
true, all internal console.log / console.warn / console.error calls become no-ops.
Option 2: optional logger
Accept an optional logger on the constructor that conforms to a small interface and route all internal logs through it:
interface Logger {
info(...args: unknown[]): void;
warn(...args: unknown[]): void;
error(...args: unknown[]): void;
}
const primus = new PrimusZKTLS({ logger: pino() });
- Defaults to
console, so current behavior is preserved.
- Covers the "I want to keep the diagnostic output but in structured form" case that Option 1 intentionally does not.
Happy to open a PR for whichever direction you prefer.
Summary
The SDK writes directly to
console.log/console.warnfrom several internal code paths. When embedded in a Node service that uses a structured logger (pino, winston, etc.), these unstructured lines pollute stdout and break log ingestion. There's currently no way to disable them without monkey-patchingconsole.Example output per attestation
The
attestationListline is particularly heavy since it includes the full signed attestation on every call.A few of the call sites (there are more):
src/index.ts#L391,src/classes/Contract.ts#L43,src/utils.ts#L158.Proposed fix
Option 1:
silentflagAdd a
silentoption on the constructor:false, so current behavior is preserved.true, all internalconsole.log/console.warn/console.errorcalls become no-ops.Option 2: optional
loggerAccept an optional
loggeron the constructor that conforms to a small interface and route all internal logs through it:console, so current behavior is preserved.Happy to open a PR for whichever direction you prefer.