Skip to main content
Faremeter API
Faremeter API / logs/src

logs/src

Interfaces

ConfigureAppArgs

Defined in: packages/logs/src/index.ts:17 Configuration options for initializing the logging system.

Properties

backend?
optional backend: LoggingBackend<BaseConfigArgs>
Defined in: packages/logs/src/index.ts:21 Backend implementation to use. Auto-detected if not provided.
level?
optional level: "error" | "info" | "trace" | "debug" | "warning" | "fatal"
Defined in: packages/logs/src/index.ts:19 Minimum log level to emit. Defaults to "info".

Logger

Defined in: packages/logs/src/types.ts:19

Methods

debug()
debug(…args): void
Defined in: packages/logs/src/types.ts:20
Parameters
args
LogArgs
Returns
void
error()
error(…args): void
Defined in: packages/logs/src/types.ts:23
Parameters
args
LogArgs
Returns
void
fatal()
fatal(…args): void
Defined in: packages/logs/src/types.ts:24
Parameters
args
LogArgs
Returns
void
info()
info(…args): void
Defined in: packages/logs/src/types.ts:21
Parameters
args
LogArgs
Returns
void
warning()
warning(…args): void
Defined in: packages/logs/src/types.ts:22
Parameters
args
LogArgs
Returns
void

LoggingBackend

Defined in: packages/logs/src/types.ts:37 Backend implementation for the logging system. Backends handle log output destinations (console, file, external service) and can be swapped at runtime via configureApp.

Type Parameters

TConfig
TConfig extends BaseConfigArgs = BaseConfigArgs Configuration options for this backend.

Methods

configureApp()
configureApp(args): Promise<void>
Defined in: packages/logs/src/types.ts:45 Initializes the backend with the given configuration.
Parameters
args
TConfig Backend-specific configuration including minimum log level.
Returns
Promise<void>
getLogger()
getLogger(subsystem): Logger
Defined in: packages/logs/src/types.ts:53 Creates a logger scoped to a subsystem hierarchy.
Parameters
subsystem
readonly string[] Hierarchical category for the logger (e.g., ["faremeter", "client"]).
Returns
Logger A logger instance for the specified subsystem.

Type Aliases

Context

Context = Record<string, unknown>
Defined in: packages/logs/src/types.ts:16

LogArgs

LogArgs = [string, Context]
Defined in: packages/logs/src/types.ts:17

LogLevel

LogLevel = typeof LogLevels[number]
Defined in: packages/logs/src/types.ts:10

Variables

ConsoleBackend

const ConsoleBackend: LoggingBackend
Defined in: packages/logs/src/console.ts:22 Logging backend that outputs to the browser or Node.js console. This is the default fallback backend when logtape is not available. It uses native console.debug, console.info, console.warn, and console.error methods for output.

LogLevels

const LogLevels: readonly ["trace", "debug", "info", "warning", "error", "fatal"]
Defined in: packages/logs/src/types.ts:1

Functions

configureApp()

configureApp(args): Promise<void>
Defined in: packages/logs/src/index.ts:49 Initializes the global logging system. Call this once at application startup to configure the log level and backend. If no backend is specified, logtape is used when available, otherwise falls back to console output.

Parameters

args
ConfigureAppArgs = {} Configuration options for level and backend.

Returns

Promise<void>

Example

await configureApp({ level: "debug" });

getLogger()

getLogger(subsystem): Promise<Logger>
Defined in: packages/logs/src/index.ts:69 Creates a logger for a specific subsystem. The returned logger automatically adapts if the backend changes after creation (e.g., when configureApp is called later).

Parameters

subsystem
readonly string[] Hierarchical category path for the logger.

Returns

Promise<Logger> A logger instance scoped to the subsystem.

Example

const logger = await getLogger(["faremeter", "client"]);
logger.info("Client initialized", { version: "1.0.0" });