@metreeca/core - v0.9.7
    Preparing search index...

    Module logger

    Logging framework providing a simplified facade over LogTape.

    Offers streamlined logger management for TypeScript/JavaScript applications with:

    Category System

    LogTape uses a hierarchical category system for organizing loggers. This module automatically generates category arrays from import.meta.url, distinguishing between internal project code and external dependencies:

    • Internal modules (project code):

      • Prefixed with "." (for instance, [".", "utils", "helper"])
    • External modules (from node_modules/):

      • Non-scoped packages: Prefixed with "@" (for instance, ["@", "lodash", "map"])
      • Scoped packages: Inherently prefixed (for instance, ["@scope", "pkg", "module"])

    Usage

    import { log } from '@metreeca/core/logger';

    // Get logger for current module (auto-configures console logging for internal modules)

    const logger = log(import.meta.url);

    logger.info("Application started");
    logger.debug("Processing request", { id: 123 });
    logger.error("Failed to connect", error);

    // Configure logging levels (call once at startup)

    log({

    // All internal code at debug level
    ".": "debug",

    // Specific internal module at info level
    "./utils": "info"

    // Specific external package at trace level
    "@/lodash": "trace",

    });

    For advanced use cases, the log function accepts full LogTape configuration objects with custom sinks, filters, and logger hierarchies.

    Functions

    log

    Retrieves the root logger instance.

    message

    Extracts a readable message string from an unknown value.

    time

    Executes an asynchronous task and monitors its execution time.

    guard

    Wraps an asynchronous function with error handling and logging.