Stratal API Reference
    Preparing search index...

    Class LoggerService

    Logger Service

    Main logging facade with optional request context enrichment. Singleton service that can be enriched with request context via withContext().

    Features:

    • Optional request context enrichment (userId) via withContext()
    • Async logging via ctx.waitUntil() for non-blocking performance
    • Multi-transport support (console, future Sentry/Cloudflare Analytics)
    • Configurable formatters (JSON production, Pretty development)
    • Log level filtering based on environment

    Architecture:

    • Singleton service (available during initialization and request handling)
    • RouterContext optionally set via withContext() method
    • Uses ConfigService for all configuration (NEVER process.env)
    • Transports and formatters injected via DI
    @Transient()
    export class UserService {
    constructor(
    @inject(LOGGER_TOKENS.LoggerService)
    private readonly logger: LoggerService
    ) {}

    async createUser(input: CreateUserInput) {
    this.logger.info('Creating user', { email: input.email })
    }
    }
    // In RequestScopeService
    const baseLogger = globalContainer.resolve<LoggerService>(LOGGER_TOKENS.LoggerService)
    const requestLogger = baseLogger.withContext(routerContext)
    requestContainer.register(LOGGER_TOKENS.LoggerService, { useValue: requestLogger })
    Index

    Constructors

    Methods

    Constructors

    Methods