Logger
A Logger interface is injected into the handler context with ctx.log. It is bound to the namespace sqd:processor:mapping. The context logger is a recommended way of logging for squid processors.
Logger exposes the following logging levels, in order of increasing severity:
TRACEDEBUGINFOWARNERRORFATAL
By default, the logging level is set to INFO.
And here is an example:
processor.run(new TypeormDatabase(), async (ctx) => {
ctx.log.trace("Trace Log example");
ctx.log.debug("Debug Log example");
ctx.log.info("Info Log example");
ctx.log.warn("Warn Log example");
ctx.log.error("Error Log example");
ctx.log.fatal("Fatal Log example")
});
Overriding the log level
The log level can be overridden by setting a matching namespace selector to one of the SQD_TRACE, ..., SQD_FATAL env variables. In particular, to set the handler logs level to DEBUG set the environment variable SQD_DEBUG to sqd:processor:mapping:
SQD_DEBUG=sqd:processor:mapping
The namespace selector supports wildcards, so one can also enable internal debug logs of @subsquid/substrate-processor with
SQD_DEBUG=sqd:processor*
since all processor context loggers inherit the processor-level namespace sqd:processor.
Accessing logs of a deployed Squid
Processor logs can be inspected once the squid is deployed to Cloud:
sqd logs -n <name> -s <slot> -f --level=<level>
or
sqd logs -n <name> -t <tag> -f --level=<level>
For older version-based deployments...
...the slot string is v${version}, so use
sqd logs -n <name> -s v<version> -f --level=<level>
Check out the Slots and tags guide to learn more.
The available levels are:
infowarningdebugerror- will fetch messages emitted byctx.log.errorctx.log.fatalctx.log.trace
See CLI Reference or sqd logs --help for a full list of log options supported by SQD Cloud.