Skip to main content
The @talosjs/logger component is a multi-backend logging layer. Every logger implements the same ILogger interface (init, error, warn, info, debug, log, success), so you can write to the terminal in development and ship to Better Stack in production while the call sites stay the same. Each method takes a message, an optional structured data object, and per-call display options. error additionally accepts an IException and logs its name, status, and stack trace.

What you get

TerminalLogger, BetterstackLogger, and BetterstackExceptionLogger all implement ILogger, so swapping backends doesn’t touch your callers. The six levels (error, warn, info, debug, log, and success) map to the ELogLevel enum, each rendered with its own color and symbol in the terminal. Pass a typed data object alongside the message and the backend serializes it for you. error() takes either a string or an IException, recording the exception’s name, status, and structured stack trace when given one. Registration is a decorator, and the container resolves the logger.

How it works

You pick (or implement) a backend and register it. Calls go through the ILogger methods; the backend handles formatting, serialization, and transport. Every method shares the same ELogLevel levels: ERROR, WARN, INFO, DEBUG, LOG, SUCCESS. The built-in backends differ in where logs go, not in how you call them: TerminalLogger accepts LoggerOptionsType per call (showArrow, showTimestamp, showLevel, and useSymbol) to control how each line is rendered. Error and ERROR-level lines go to stderr, and everything else goes to stdout.

Environment variables

Only the production backends need configuration. TerminalLogger needs none.

Decorator and usage

@decorator.logger()

Registers a logger class with the container. It accepts an optional scope (defaults to EContainerScope.Singleton). All built-in loggers are decorated, and you use it to register custom loggers that implement ILogger.
Resolve a logger from the container and call its level methods:
error() accepts a plain message or an IException. Given an exception, it records the name, status, and stack trace automatically:
Inject a logger where you need it:

Exceptions

The component throws LoggerException when a backend is misconfigured. It carries a machine-readable key, a human-readable message, a data object, and an InternalServerError status.

Logging well

Pick the backend per environment: TerminalLogger for local and dev, BetterstackLogger or BetterstackExceptionLogger for production, with the call sites identical either way. Pass structured data rather than interpolated strings, keeping the message stable and moving variable detail into the data object so logs stay searchable. Match the level to the meaning, reserving error for failures, warn for recoverable issues, success for completed operations, and debug for diagnostics. When something throws, log the IException itself instead of its message string, so the name, status, and stack trace are all captured. Keep data serializable, since backends serialize the values; avoid class instances, functions, and circular references. In custom backends, throw LoggerException with a constant key and put the variable detail in data.

CLI command

Scaffold a logger class and its test file with the generator. It writes the class under modules/<module>/src/loggers/<Name>Logger.ts and installs @talosjs/logger if it is missing.
The generated class starts as an ILogger stub, ready for you to implement each level method:
See logger:create for the full command reference.

Use with Claude and Codex

The generator ships a matching logger:create skill. It runs the scaffold and then guides your AI agent through completing the logger: implementing init, log, debug, info, success, warn, and error against a real transport and wiring up its dependencies. Initialize the skills once for your agent:
Then ask Claude in natural language. It maps the request to the generator, runs it, and fills in the implementation:
Prompt
For example, the prompt above maps to logger:create --name=Payments --module=payments, then implements the ILogger methods against your chosen transport.