Docs Guides

Logging and debugging

Turn on debug output, route it to your own logger and diagnose a connection.

The SDK is almost silent by default. The only line it prints without debug is a warning when the host returns entries that are not valid addresses (see below).

Enable debug output

WalletBridgeClient prints warnings only when debug is true. The messages cover recoverable situations such as an auto-connect failure, an event listener that threw, a late response that was ignored, and a failed haptic or orientation call outside the App Center iframe. Every line is prefixed with [WalletBridgeClient].

import { WalletBridgeClient } from '@hydraone-sdk/core';

const client = new WalletBridgeClient({ hostOrigin: 'https://alpha.hydraone.app', debug: true });

Use your own logger

Pass any object with warn and error methods. console already satisfies the Logger interface:

import { WalletBridgeClient, type Logger } from '@hydraone-sdk/core';

const logger: Logger = {
  warn: (message, ...args) => console.warn(`[sdk] ${message}`, ...args),
  error: (message, ...args) => console.error(`[sdk] ${message}`, ...args),
};

export const client = new WalletBridgeClient({ hostOrigin: 'https://alpha.hydraone.app', debug: true, logger });

To adapt a logging library, forward the two methods to it. With debug: false the logger is only called for the invalid-address warning.

export interface Logger {
  warn(message: string, ...args: unknown[]): void;
  error(message: string, ...args: unknown[]): void;
}

What is and is not logged

  • Logged: short English messages and the error object that triggered them.
  • Not logged by the client: request payloads, signatures, tokens or balances.
  • With debug: true, an address query that skips entries that are not valid addresses warns with [WalletBridgeClient] <QUERY>: skipped N invalid address(es) from the host and passes only the skipped entries.
  • Errors you catch yourself carry details, which can echo host data. See Errors before forwarding them.

Other components

The logger option applies to WalletBridgeClient. On the host side, createHost from @hydraone-sdk/host takes its own logger (warn and error, default console) and always logs blocked origins and failed requests, prefixed with [Host].

Diagnosing a connection

To see why a connection fails, run the health check instead of reading logs. It reports iframe, latency and storage problems with hints:

import { WalletBridgeClient, checkBridgeHealth } from '@hydraone-sdk/core';

const client = new WalletBridgeClient({
  hostOrigin: 'https://alpha.hydraone.app',
});
await client.init(); // the latency check fails with ERR_BRIDGE_NOT_CONNECTED before the handshake

const report = await checkBridgeHealth(client, { warningThresholdMs: 200, skipStorageCheck: true });
for (const check of report.checks) {
  console.log(check.status, check.name, check.message, check.hint ?? '');
}

See Testing and health checks.