Skip to main content
@subsquid/logger is Squid SDK’s structured logger. It is a small native implementation, not a Pino logger. The package exports a createPinoSink() adapter for applications that want to route its records through Pino. Legacy chain-specific processors inject a Logger into the handler context as ctx.log, bound to the sqd:processor:mapping namespace. Portal-native processors built with @subsquid/batch-processor do not inject a logger. Create one explicitly:
Logger exposes the following logging levels, in order of increasing severity:
  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
By default, the logging level is set to INFO. Each level accepts either a message or an attributes object followed by a message:

Child loggers

child() creates a logger that inherits its parent’s namespace and attributes. It has two overloads:
A string appends a colon-separated namespace. An object adds structured fields without changing the namespace. Parent and child attributes are merged, with child attributes taking precedence:

Output format and destination

The built-in sinks always write to standard error. Output format is selected when @subsquid/logger is first imported: Set the variable before starting Node because the selection is made at module initialization:

Overriding the log level

The log level can be overridden by setting a matching namespace selector to one of the SQD_TRACE, …, SQD_FATAL environment variables. To set the handler log level to DEBUG, set SQD_DEBUG to sqd:processor:mapping:
The namespace selector supports wildcards, so you can also enable internal processor debug logs with:
Processor context loggers inherit the processor-level namespace sqd:processor.

Accessing logs of a deployed Squid

Processor logs can be inspected after the squid is deployed to Cloud:
or
…the slot string is v${version}, so use
Check out the Slots and tags guide to learn more.
The available filters are info, warning, debug, and error. The error filter includes messages emitted through ctx.log.error, ctx.log.fatal, and ctx.log.trace. See CLI Reference or sqd logs --help for a full list of log options supported by SQD Cloud.