Skip to content
Warlock.js v4

Types

Every type exported from @warlock.js/logger.

The five severity levels.

type LogLevel = "debug" | "info" | "warn" | "error" | "success";

success ranks the same as info — it’s informational, not a warning. Ranking for minLevel: debug < info ≈ success < warn < error.

The entry passed through log.log(...) and to every channel’s log().

type LoggingData = {
type: "info" | "debug" | "warn" | "error" | "success";
module: string;
action: string;
message: any;
context?: Record<string, any>;
};

LoggingData without type — the object form accepted by the per-level shortcuts (log.info({...})), where the level is implied by the method.

type OmittedLoggingData = Omit<LoggingData, "type">;

The serialized shape stored by the file channels (one per buffered entry).

type LogMessage = {
content: string;
level: LogLevel;
date: string;
module: string;
action: string;
stack?: string;
context?: Record<string, any>;
timestamp?: string;
};

The interface a channel must satisfy. LogChannel already implements it.

interface LogContract {
name: string;
description?: string;
terminal?: boolean;
log(data: LoggingData): void | Promise<void>;
flushSync?(): void;
}

The shared options every built-in channel config extends.

type BasicLogConfigurations = {
/** Restrict which levels this channel handles. Omit for all levels. */
levels?: LogLevel[];
/** Day.js format strings for the date/time in each entry. */
dateFormat?: {
date?: string;
time?: string;
};
/** Predicate to decide whether an entry should be logged. */
filter?: (data: LoggingData) => boolean;
/** Add extra context to the entry. */
context?: (data: LoggingData) => Promise<Record<string, any>>;
/** Channel-specific redaction — additive on top of the logger-wide floor. */
redact?: RedactConfig;
};

The process events enableAutoFlush() can hook.

type AutoFlushEvent =
| "SIGINT"
| "SIGTERM"
| "SIGHUP"
| "SIGBREAK"
| "SIGUSR2"
| "beforeExit";

Signals are flushed then re-raised so Node’s default exit runs; beforeExit is flushed in place. See Shutdown & flushing.

type RedactConfig = {
/** Dotted glob path patterns to redact, evaluated against LoggingData. */
paths: string[];
/** Replacement applied at each match. @default "[REDACTED]" */
censor?: RedactCensor;
};
type RedactCensor =
| string
| ((value: any, path: string) => any);

A literal string replaces every match; a function receives the original value plus the dotted path and returns the replacement. See Redaction.

type DebugMode = "daily" | "monthly" | "yearly" | "hourly";