A logging wrapper based on pino, providing high-performance structured JSON logs. It is recommended to use ctx.logger instead of console for easier log collection and analysis.
ctx.logger can be used in all RunJS scenarios for debugging, error tracking, performance analysis, etc.
ctx.logger is an instance of engine.logger.child({ module: 'flow-engine' }), which is a pino child logger with a module context.
pino supports the following levels (from highest to lowest):
| Level | Method | Description |
|---|---|---|
fatal | ctx.logger.fatal() | Fatal error, usually leading to process exit |
error | ctx.logger.error() | Error, indicating a failed request or operation |
warn | ctx.logger.warn() | Warning, indicating potential risks or abnormal situations |
info | ctx.logger.info() | General runtime information |
debug | ctx.logger.debug() | Debugging information, used during development |
trace | ctx.logger.trace() | Detailed trace, used for deep diagnostics |
The recommended format is level(msg, meta): the message comes first, followed by an optional metadata object.
pino also supports level(meta, msg) (object first) or level({ msg, ...meta }) (single object), which can be used as needed.
It is recommended to use ctx.logger directly to obtain structured JSON logs. If you are accustomed to using console, the mappings are: console.log → ctx.logger.info, console.error → ctx.logger.error, console.warn → ctx.logger.warn.
pino outputs structured JSON, where each log entry contains:
level: Log level (numeric)time: Timestamp (milliseconds)msg: Log messagemodule: Fixed as flow-enginechild() also follow the level(msg, meta) recommendation.