@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 theILogger 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.
error() accepts a plain message or an IException. Given an exception, it records the name, status, and stack trace automatically:
Exceptions
The component throwsLoggerException 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 undermodules/<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:
Use with Claude and Codex
The generator ships a matchinglogger: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:
- Claude
- Codex
Prompt
logger:create --name=Payments --module=payments, then implements the ILogger methods against your chosen transport.