Reference
leylines
Types
CollapsedValue
Stored value that was collapsed out of a default entry payload.
export interface CollapsedValue {
id: string;
entryId: string;
path: string;
value: JsonValue;
}
Properties
idStable identifier used withexpand.entryIdEntry id that owns the collapsed value.pathPath inside the entry where the value was collapsed.valueFull JSON-compatible collapsed value.
ErrorDetails
Normalized error details stored with an error-level or error-bearing entry.
export interface ErrorDetails {
name?: string;
message: string;
stack?: string;
cause?: JsonValue;
}
Properties
nameError class or constructor name when available.messageHuman-readable error message.stackStack trace when available and safe to persist.causeJSON-compatible representation of the error cause when present.
JsonObject
JSON object used for structured metadata and queryable properties.
export type JsonObject = {
[key: string]: JsonValue;
};
JsonPrimitive
JSON scalar value accepted by Leylines metadata and properties.
export type JsonPrimitive = string | number | boolean | null;
JsonValue
JSON-compatible value accepted by Leylines metadata and properties.
export type JsonValue = JsonPrimitive | JsonValue[] | {
[key: string]: JsonValue;
};
LogEntry
Persisted log entry returned from writes, queries, and tails.
export interface LogEntry {
id: string;
sequence: number;
timestamp: string;
level: LogLevel;
scope: string;
message: string;
metadata: JsonObject;
properties: JsonObject;
error?: ErrorDetails;
}
Properties
idStable unique identifier for this entry.sequenceMonotonic store-local sequence used to make ordering deterministic.timestampISO timestamp for when the entry occurred.levelEntry severity.scopeDotted domain scope that produced the entry.messageShort human-readable event message.metadataRuntime context that is useful for display but not the primary query model.propertiesStructured event properties intended for filtering and correlation.errorNormalized error details when an error was attached.
LogEntryInput
Input accepted by store-level append operations.
export interface LogEntryInput {
id?: string;
timestamp?: Date | string;
level: LogLevel;
scope: string;
message: string;
metadata?: JsonObject;
properties?: JsonObject;
error?: unknown;
}
Properties
idOptional caller-provided entry identifier. A generated UUID is used when omitted.timestampOptional occurrence time. The current time is used when omitted.levelEntry severity.scopeDotted domain scope that produced the entry.messageShort human-readable event message.metadataRuntime context that is useful for display but not the primary query model.propertiesStructured event properties intended for filtering and correlation.errorError-like value to normalize and persist with the entry.
LoggerOptions
Base scope and inherited context for a scoped logger.
export interface LoggerOptions {
scope: string;
properties?: JsonObject;
metadata?: JsonObject;
}
Properties
scopeDotted domain scope assigned to entries from this logger.propertiesStructured properties inherited by every entry from this logger.metadataMetadata inherited by every entry from this logger.
LoggerWriteOptions
Per-entry options accepted by ScopedLogger write methods.
export interface LoggerWriteOptions {
properties?: JsonObject;
metadata?: JsonObject;
error?: unknown;
timestamp?: Date | string;
}
Properties
propertiesStructured properties merged over the logger's inherited properties.metadataMetadata merged over the logger's inherited metadata.errorError-like value to normalize and persist with the entry.timestampOccurrence time. The current time is used when omitted.
š LoggerWriteOptions on GitHub
LogLevel
Severity assigned to a log entry.
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
LogPage
Page of query results with stable entry-id cursors.
export interface LogPage {
entries: LogEntry[];
nextBefore?: string;
nextAfter?: string;
}
Properties
entriesEntries matched by the query in chronological order.nextBeforeCursor for entries before the first returned entry.nextAfterCursor for entries after the last returned entry.
LogQuery
Query criteria shared by the Node API and CLI.
export interface LogQuery {
since?: Date | string;
until?: Date | string;
before?: string;
after?: string;
levels?: LogLevel[];
minLevel?: LogLevel;
scope?: string;
scopePrefix?: string;
text?: string;
regex?: string | RegExp;
properties?: PropertyFilter[];
includeDebug?: boolean;
limit?: number;
}
Properties
sinceInclude entries at or after this timestamp.untilInclude entries at or before this timestamp.beforeReturn entries that sort before this entry id.afterReturn entries that sort after this entry id.levelsExact levels to include.minLevelInclude entries at this severity or higher.scopeExact scope to include.scopePrefixScope prefix to include, matching both the prefix itself and dotted children.textCase-sensitive message substring filter.regexRegular expression tested against entry messages.propertiesEquality filters over structured properties.includeDebugInclude debug entries, which are hidden by default.limitMaximum number of entries to return.
OpenLogStoreOptions
Options for opening the low-level durable log store.
interface OpenLogStoreOptions {
path: string;
retention?: RetentionOptions;
redaction?: RedactionOptions;
collapseAboveBytes?: number;
}
Properties
pathSQLite store path. Parent directories are created automatically.retentionRetention policy applied during store maintenance.redactionRedaction rules applied before entries are persisted.collapseAboveBytesByte threshold above which large JSON values are collapsed for default views.
š OpenLogStoreOptions on GitHub
OpenScopedLogsOptions
Options for opening the high-level Scoped Logs API.
export interface OpenScopedLogsOptions {
path?: string;
production?: boolean;
retention?: RetentionOptions;
redaction?: RedactionOptions;
collapseAboveBytes?: number;
}
Properties
productionEnable logging whenNODE_ENVisproduction. Disabled by default.retentionRetention policy applied during store maintenance.redactionRedaction rules applied before entries are persisted.collapseAboveBytesByte threshold above which large JSON values are collapsed for default views.
š OpenScopedLogsOptions on GitHub
PropertyFilter
Equality filter against a top-level or dotted path inside entry properties.
export interface PropertyFilter {
path: string;
equals: JsonValue;
}
Properties
pathProperty name or dotted path such asrequest.id.equalsJSON value that must equal the value atpath.
RedactionOptions
Redaction configuration applied before entries are persisted.
export interface RedactionOptions {
rules?: RedactionRule[];
}
Properties
rulesAdditional rules appended to Leylines' built-in secret-looking defaults.
š RedactionOptions on GitHub
RedactionRule
Rule that replaces sensitive property names or string values before persistence.
export interface RedactionRule {
name?: string | RegExp;
value?: string | RegExp;
replacement?: string;
}
Properties
nameProperty name or name pattern to redact.valueString value or value pattern to redact.replacementReplacement text. Defaults to[REDACTED].
RetentionOptions
Retention policy applied during store maintenance.
export interface RetentionOptions {
maxEntries?: number;
maxAgeMs?: number;
}
Properties
maxEntriesMaximum number of newest entries to retain.maxAgeMsMaximum entry age in milliseconds.
š RetentionOptions on GitHub
ScopedLogs
High-level handle for writing, querying, tailing, and closing a log store.
export interface ScopedLogs {
readonly enabled: boolean;
readonly store: LogStore | undefined;
logger(options: LoggerOptions | string): ScopedLogger;
query(query?: LogQuery): ReturnType<LogStore['query']>;
tail(query?: LogQuery, options?: {
signal?: AbortSignal;
}): AsyncIterable<LogEntry>;
expand(id: string): ReturnType<LogStore['expand']>;
listScopes(): string[];
close(): void;
}
Properties
enabledWhether this handle writes to a durable store.storeUnderlying durable store, absent when production logging is disabled.loggerCreate a logger for a scope or full logger options.queryQuery stored entries.tailStream entries appended after subscription that match the query.expandRetrieve a full collapsed value by collapsed value id.listScopesList scopes observed in the store.closeClose the underlying store.
Functions
defaultStorePath
Resolve the inferred local store path.
export function defaultStorePath(): string;
š defaultStorePath on GitHub
openLogStore
Open or create a low-level durable log store.
export function openLogStore(options: OpenLogStoreOptions): LogStore;
openScopedLogs
Open the high-level Scoped Logs API around a durable local store.
export function openScopedLogs(options?: OpenScopedLogsOptions): ScopedLogs;
Classes
LogStore
Durable local log store backed by SQLite.
export class LogStore {
#private;
/** Absolute SQLite database path backing this store. */
readonly path: string;
/** Open or create a SQLite log store. */
constructor(options: OpenLogStoreOptions);
/** Append an entry, apply redaction, and return the persisted entry. */
write(input: LogEntryInput): LogEntry;
/** Query entries in chronological order with stable pagination cursors. */
query(query?: LogQuery): LogPage;
/** List all observed scopes in lexical order. */
listScopes(): string[];
/** Retrieve a collapsed value by id, or `undefined` when it is not present. */
expand(id: string): CollapsedValue | undefined;
/** Stream entries appended after subscription that match the query. */
tail(query?: LogQuery, options?: {
signal?: AbortSignal;
}): AsyncIterable<LogEntry>;
/** Close the SQLite database. Subsequent store operations throw. */
close(): void;
}
ScopedLogger
Logger that writes entries to a LogStore under a stable domain scope.
export class ScopedLogger {
#private;
/** Dotted domain scope assigned to entries from this logger. */
readonly scope: string;
/** Create a logger backed by `store` with inherited scope, properties, and metadata. */
constructor(store: LogStore | undefined, options: LoggerOptions);
/** Create a child logger with merged inherited context and a nested scope. */
child(options?: Partial<LoggerOptions> & {
scope?: string;
}): ScopedLogger;
/** Write a debug entry. Debug entries are hidden from default queries unless requested. */
debug(message: string, options?: LoggerWriteOptions): LogEntry | undefined;
/** Write an info entry. */
info(message: string, options?: LoggerWriteOptions): LogEntry | undefined;
/** Write a warning entry. */
warn(message: string, options?: LoggerWriteOptions): LogEntry | undefined;
/** Write an error entry, optionally with normalized error details. */
error(message: string, options?: LoggerWriteOptions): LogEntry | undefined;
/** Write an entry at an explicit level. */
write(level: LogLevel, message: string, options?: LoggerWriteOptions): LogEntry | undefined;
}