Skip to content

API Reference

This page lists every public entry point Logaria exports. It follows the source exports exactly — no aspirational shapes, no aliases — so it stays accurate as the package evolves.

For tutorials and usage patterns, see the Getting Started and topic guides. This page is the spec.

logaria

The root entry. Use this in applications, scripts, and packages that own the default scope.

ts
import { createLogger, resetLoggerConfig, setLoggerConfig } from 'logaria';
APISignatureNotes
createLogger(options: { main: string }) => LoggerCreates or reuses a main logger in the default scope. Call .getLoggerByGroup(group) before logging.
setLoggerConfig(config: LoggerConfig) => voidSets the default runtime config for direct non-plugin usage. Throws in plugin-controlled runtimes.
resetLoggerConfig() => voidClears the default runtime config for direct non-plugin usage. Throws in plugin-controlled runtimes.

The root entry does not export resolveLoggerConfig; import that from logaria/core.

Logger Objects

Loggers returned by createLogger and createScopedLogger expose the same surface:

ts
const logger = createLogger({ main: '@acme/docs' }).getLoggerByGroup('build');

logger.info('message');
logger.success('message');
logger.warn('message');
logger.error('message');
logger.debug('message');

info, success, warn, and error accept an optional elapsed log option:

ts
logger.info('finished', { elapsedTimeMs: 12.34 });

debug accepts only the message — diagnostic output stays cheap.

logaria/helper

Stateless helpers for elapsed timing and error formatting. No runtime config.

ts
import { createElapsedTimer, formatDebugMessage, formatErrorMessage } from 'logaria/helper';
APISignatureNotes
createElapsedTimer() => () => { elapsedTimeMs: number }Creates a timer function suitable for logger elapsed options.
formatDebugMessage(options: DebugMessageOptions) => stringFormats structured debug context, decision, summary, and timing fields.
formatErrorMessage(error: unknown) => stringConverts unknown thrown values into readable strings.

createElapsedLogOptions and formatElapsedTime are internal module exports and are not part of the logaria/helper package entry.

logaria/plugin

The universal bundler adapter and supporting constants.

ts
import { loggerPlugin, transformLoggerTreeShaking } from 'logaria/plugin';
APINotes
loggerPluginUniversal unplugin adapter with .vite, .rollup, .rolldown, .esbuild, .webpack, .rspack, and .farm.
transformLoggerTreeShakingDirect transform helper used by tests and advanced tooling.
DEFAULT_LOGGER_MODULE_IDThe public logger module id used by the transform.
LOGGER_TREE_SHAKING_PLUGIN_NAMEThe transform plugin name.

Most applications need only loggerPlugin. See Bundler Plugin for usage.

LoggerPluginOptions

ts
interface LoggerPluginOptions {
  config?: LoggerConfig | null;
  treeshake?: boolean;
}
FieldDefaultMeaning
confignullRuntime LoggerConfig injected into the bundle. Omit to use the default policy.
treeshakefalseSet true to enable build-time pruning. No effect in dev or watch mode.

logaria/core

Scoped APIs for host integrations and tooling.

ts
import {
  createScopedLogger,
  getScopedLoggerConfig,
  resetScopedLoggerConfig,
  resolveLoggerConfig,
  setScopedLoggerConfig,
  shouldSuppressLog,
} from 'logaria/core';
APISignatureNotes
createScopedLogger(options: { main: string }, scopeId: string) => LoggerCreates or reuses a logger in a registered explicit scope.
getScopedLoggerConfig(scopeId: string) => LoggerConfig | undefinedReads the raw config for a registered scope.
setScopedLoggerConfig(scopeId: string, config: LoggerConfig) => voidRegisters or updates an explicit scope.
resetScopedLoggerConfig(scopeId: string) => voidRemoves scope config.
shouldSuppressLog(kind, context, scopeId?) => booleanReturns whether a log should be hidden.
resolveLoggerConfig(config: LoggerConfig) => NormalizedLoggerConfigNormalizes and validates public config for host packages.

See Scoped Integrations for usage patterns.

logaria/core/helper

ts
import { DEFAULT_LOGGER_SCOPE_ID, createLoggerScopeId } from 'logaria/core/helper';
APINotes
DEFAULT_LOGGER_SCOPE_IDInternal default scope id exposed for host integrations.
createLoggerScopeIdCreates a unique scope id string for explicit scope ownership.

logaria/types

Public TypeScript types — use these when authoring presets, accepting user config, or extending Logaria.

ts
import type {
  LoggerConfig,
  LoggerPresetPlugin,
  LoggerVisibilityLevel,
  LogKind,
} from 'logaria/types';

The types entry exposes public runtime config, rule, logger, plugin, and transform result types for TypeScript consumers. Notable exports:

TypeUse case
LoggerConfigThe shape accepted by setLoggerConfig, loggerPlugin, and scoped APIs — see Core Concepts.
LoggerPresetPluginPreset author entry point — see Rules & Presets.
LoggerVisibilityLevelUnion of allowed level strings: 'error' | 'warn' | 'info' | 'success'.
LogKindUnion of all log kinds: visibility levels plus 'debug'.
DebugMessageOptionsArgument shape for formatDebugMessage.
Logger / ScopedLoggerLogger object shapes returned by createLogger / .getLoggerByGroup.

Released under the MIT License. (0463eff)