Factory for creating Logger instances

The factory is initialized with one or more log handlers. All loggers created from the factory will write to all configured handlers.

Example

// Get the logger factory from the platform
const loggerFactory = platform.get('logger');

// Create loggers for different components
const httpLogger = loggerFactory.createLogger('http');
const authLogger = loggerFactory.createLogger('auth');

// Register a custom handler dynamically
const customHandler = new MyCustomHandler();
loggerFactory.addHandler(customHandler);

// Retrieve all logs
const allLogs = await loggerFactory.getLogs();

// Clear all logs
await loggerFactory.clearLogs();

Hierarchy

  • LoggerFactory

Methods

  • Registers a new handler with the factory

    The handler will receive all future log entries from all loggers (both existing and newly created). Historical logs are not replayed.

    Parameters

    Returns void

  • Clears logs from all handlers that support storage

    This method clears logs from all handlers that implement LogStore. Handlers that don't support clearing (like console) are ignored.

    Returns Promise<void>

  • Creates a logger instance for a specific scope/category

    Returns

    A logger instance that writes to all configured handlers

    Parameters

    • scope: string

      The scope or category for the logger (e.g., 'http', 'auth', 'component-name')

    Returns Logger

  • Retrieves logs from all handlers that support storage

    This method aggregates logs from all handlers that implement LogStore. Handlers that don't support log retrieval (like console) are ignored.

    Returns

    Array of all log entries from all storage handlers

    Returns Promise<LogEntry[]>

  • Removes a handler from the factory

    Returns

    true if the handler was removed, false if it was not found

    Parameters

    Returns boolean