Skip to Content
API Reference@parity/product-sdk-loggerOverview

@parity/product-sdk-logger

Structured, namespace-filtered logging for the SDK.

Each package calls createLogger(namespace) to emit structured LogEntry records; the host application calls configure once to set the log level, decide which namespaces are enabled, and route entries into its own observability stack via a custom LogHandler.

npm install @parity/product-sdk-logger

Exports

Functions

NameSummary
configure()Apply global logger configuration. Merges into prior settings — passed fields
createLogger()Create a Logger bound to a namespace.

Interfaces

NameSummary
LogEntryA structured record emitted by a Logger.
LoggerA namespaced logger. Each method emits a LogEntry at the matching LogLevel, or no-ops when filtered out by the current configuration.
LoggerConfigGlobal configuration for the logger system, applied via configure.

Type Aliases

NameSummary
LogHandlerCustom sink for log records. When set via configure it replaces the default console.* output and receives every LogEntry that passes the level filter.
LogLevelSeverity ranking — "error" is the highest, then "warn", "info", "debug". The configured level is the lowest severity that gets emitted; less-severe entries are dropped.

Functions

configure()

Apply global logger configuration. Merges into prior settings — passed fields replace, omitted fields are left alone — and takes effect immediately for every Logger, present and future.

configure(config: LoggerConfig): void

createLogger()

Create a Logger bound to a namespace.

The namespace is attached to every LogEntry the logger emits and is what LoggerConfig.namespaces matches against. Convention is package:area — e.g. "signer:dev", "chain-client".

createLogger(namespace: string): Logger

Interfaces

interface LogEntry

A structured record emitted by a Logger.

Properties

data
propertyoptionalunknown
level
propertyLogLevel
message
propertystring
namespace
propertystring
timestamp
propertynumber

interface Logger

A namespaced logger. Each method emits a LogEntry at the matching LogLevel, or no-ops when filtered out by the current configuration.

Methods

debug
debug(message: string, data?: unknown): void
error
error(message: string, data?: unknown): void
info
info(message: string, data?: unknown): void
warn
warn(message: string, data?: unknown): void

interface LoggerConfig

Global configuration for the logger system, applied via configure.

Properties

handler
propertyoptionalLogHandler

Custom output handler. Replaces default console output.

level
propertyoptionalLogLevel

Minimum log level. Default: “warn”

namespaces
propertyoptionalstring[]

If set, only these namespaces use the configured level; others stay at “warn”.

Type Aliases

type LogHandler

Custom sink for log records. When set via configure it replaces the default console.* output and receives every LogEntry that passes the level filter.

type LogHandler = (entry: LogEntry) => void

type LogLevel

Severity ranking — "error" is the highest, then "warn", "info", "debug". The configured level is the lowest severity that gets emitted; less-severe entries are dropped.

type LogLevel = "error" | "warn" | "info" | "debug"
Last updated on