Skip to content

Conversation

@Ansonhkg
Copy link
Collaborator

1. Centralized logging

WHAT

  • Centralized logging for the Lit Protocol SDK. The default backend is structured pino logging, but you can attach custom transports (DataDog, Sentry, your own system) and it works in both Node.js and browsers.
  • Unified all loggings to use import { getChildLogger } from '@lit-protocol/logger'; instead of console.log.

USAGE

Centralized logging for the Lit Protocol SDK. The default backend is structured pino logging, but you can attach custom transports (DataDog, Sentry, your own system) and it works in both Node.js and browsers.

Basic usage

import { logger, getChildLogger } from '@lit-protocol/logger';

logger.info('SDK started');

const log = getChildLogger({ module: 'my-feature' });
log.debug({ foo: 'bar' }, 'doing work');

Log levels

Logging verbosity is controlled by:

  • Node.js: process.env.LOG_LEVEL
  • Browser: globalThis.LOG_LEVEL

Supported levels: silent, fatal, error, warn, info, debug, trace, debug_text.

debug_text switches the default output to console-style text (not JSON). debug2 is a deprecated alias for debug_text.

Configuration

Use setLoggerOptions at app startup to change level/name or add metadata:

import { setLoggerOptions } from '@lit-protocol/logger';

setLoggerOptions({
  level: 'info',
  name: 'MyApp',
  bindings: { app: 'my-app' },
});

2. Consolidate CURL debugging

WHAT

  • Consolidate curl debugging helpers into @lit-protocol/logger and point both Lit node and Wrapped Keys request paths at the shared implementation, preserving the opt-in LIT_DEBUG_CURL behavior while eliminating duplicated fs/path/env logic.

USAGE

# enable writing curl commands to disk
export LIT_DEBUG_CURL=1

# optional: change output directory (defaults to ./debug)
export LIT_DEBUG_CURL_DIR=./debug

After your run, copy the correlation id (for example X-Request-Id from node calls, or x-correlation-id / the Request(<id>) value from Wrapped Keys errors) and print the stored curl command:

pnpm debug:curl -- <X-Request-Id>

If you only have a prefix/substring, pnpm debug:curl will try to match it (and will list matches if more than one file fits).

// BEFORE
process.env.LOG_LEVEL = 'debug2';
logger.debug2('verbose console output');

// AFTER
process.env.LOG_LEVEL = 'debug_text'; // clearer name; debug2 still works
logger.debugText('verbose console output');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants