MCP Server Framework - v1.0.0
    Preparing search index...

    Centralized Logger Facade

    Coordinates the logging pipeline:

    1. Level filtering
    2. Message formatting (printf-style)
    3. Metadata extraction
    4. Secret scrubbing
    5. Formatting (Text/JSON)
    6. Injection prevention
    7. Output to writers (Console/File/MCP)

    Now uses LoggerResources for DI-enabled resource management, eliminating the static state anti-pattern while maintaining backward compatibility through lazy global initialization.

    // Simple usage (global resources)
    const logger = new Logger('api');
    logger.info('Request received', { method: 'GET', path: '/health' });

    // DI usage (custom resources for testing)
    const resources = new LoggerResources(config, mockDeps);
    const testLogger = new Logger({ component: 'test', resources });

    Implements

    Index

    Constructors

    Methods

    • Create a child logger with a specific component context. Uses LRU caching to avoid creating new instances while preventing memory leaks.

      Parameters

      • context: { component: string }

        The component context for the child logger

      Returns Logger

      A cached or new Logger instance

    • Create a child context that inherits from the current context. Component names are automatically concatenated.

      Parameters

      • childContext: Partial<LogContext>

        Context values for the child

      Returns LogContext

      A new child context

    • Get the current context nesting depth.

      Returns number

      The current depth

    • Execute a function with a child context.

      Type Parameters

      • T

      Parameters

      • childContext: Partial<LogContext>

        Context values for the child scope

      • fn: () => T

        The function to execute

      Returns T

      The result of the function

    • Execute a function with an extended context.

      Type Parameters

      • T

      Parameters

      • additionalContext: Partial<LogContext>

        Context values to add

      • fn: () => T

        The function to execute

      Returns T

      The result of the function

    • Clear the child logger cache. Useful for testing or when configuration changes.

      Returns void

    • Close all writers gracefully. Should be called during application shutdown.

      Returns Promise<void>

      Promise that resolves when all writers are closed

    • Reset static state (for testing purposes). Fully resets all resources.

      Returns Promise<void>