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

    Function log

    • Retrieves the root logger instance.

      Returns Logger

      The root logger with empty category

    • Retrieves a logger for the specified file path or URL.

      Extracts a hierarchical category array from the path for logger categorization.

      Automatically configures LogTape on first use if the extracted category starts with "." (local code) and LogTape is not yet configured. Default configuration includes console sink with visual severity prefixes, LogTape meta logger set to "warning" level, and local code logger at "info" level.

      Path resolution:

      • Local code (your project): Paths prefixed with ".". If URL provided (for instance, import.meta.url), pathname is parsed and segments after src/ directory are extracted (or filename only if src/ not found). Extensions and "index" segments are removed.

      • Imported packages (from node_modules/): Non-scoped packages prefixed with "@" (for instance, ["@", "lodash"]), scoped packages use two segments (for instance, ["@metreeca", "post"]). Build directories (dist, lib, build, out) and redundant package name folders are skipped. Extensions and "index" segments are removed from remaining paths.

      Parameters

      • url: string

        File path or URL to create logger category from

      Returns Logger

      Logger instance for the resolved category

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

      // file:///project/src/utils/logger.ts → [".", "utils", "logger"]
      // node_modules/lodash/map.js → ["@", "lodash", "map"]
      // node_modules/@metreeca/post/dist/index.js → ["@metreeca", "post"]
    • Retrieves a logger for the specified category array.

      Automatically configures LogTape on first use if the category starts with "." and LogTape is not yet configured. Default configuration includes console sink with visual severity prefixes, LogTape meta logger at "warning" level, and local code logger at "info" level.

      Parameters

      • category: readonly string[]

        Hierarchical logger category segments

      Returns Logger

      Logger instance for the specified category

    • Configures LogTape with category-to-level mappings.

      Configures LogTap with a single console logger using visual severity prefixes and a configuration derived from a simplified representation mapping categories to minimum log levels:

      • Each key represents a LogTape category array as a slash-separated path, with "." prefix for internal project code and "@" prefix for external dependencies (for instance, "./utils" for category [".", "utils"] or "@/lodash" for ["@", "lodash"]).

      • Each value specifies the minimum log level ("trace", "debug", "info", "warning", "error", "fatal"); invalid levels are filtered out.

      Parameters

      • config: Record<string, string>

        Path-to-level mapping for logger configuration

      Returns void

    • Configures LogTape with a complete configuration object.

      Type Parameters

      • S extends string

        Sink identifier type

      • F extends string

        Filter identifier type

      Parameters

      • config: Config<S, F>

        LogTape configuration object with sinks, filters, and loggers

      Returns void