The logger (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ency07/B2B/llms.txt
Use this file to discover all available pages before exploring further.
src/lib/utils/logger.ts) is a lightweight structured logging utility. In development it prints to the console with level, timestamp, and module tag. In production you replace the transport with Sentry, Datadog, or any external service by calling setTransport().
Never use
console.error(), console.log(), or similar raw calls in production code. Always use the module logger so logs include the module tag and can be routed to the correct external service.API Reference
createLogger(module) — default export
Creates a scoped logger for a given module. Each log call automatically includes the module name, ISO timestamp, and any extra metadata passed as options.
Logger (export type Logger = ReturnType<typeof createLogger>).
Convenience Functions (root logger)
logError and logWarn are pre-bound to the root "app" logger. Use them in utilities or top-level error boundaries where creating a named logger is unnecessary.
Child Loggers
Call.child(subModule) on any logger to create a namespaced child. The resulting module tag is "parent:child", which makes it easy to filter logs by subsystem.
setTransport(fn) — Custom Transport for Production
Replace the default console transport with any function that accepts a LogEntry. Call this once at application startup (e.g., in instrumentation.ts).
LogEntry Interface
Every call to any logger method constructs and passes a LogEntry to the active transport.
| Field | Type | Description |
|---|---|---|
level | "debug" | "info" | "warn" | "error" | Severity level |
message | string | Human-readable log message |
module | string | Module tag set in createLogger() |
timestamp | string | ISO 8601 timestamp generated at log time |
data | Record<string, unknown> | Optional structured metadata |
error | Error | Optional error object (stack trace included by default transport) |
requestId | string | Optional request correlation ID |
tenantId | string | Optional tenant identifier for multi-tenant tracing |