import { type AsyncLocalStorage } from 'node:async_hooks'; type JsonValue = | JsonObject | JsonValue[] | boolean | number | string | readonly JsonValue[] | null | undefined; /** * @see https://stackoverflow.com/a/77390832/368691 * @public */ export type JsonObject = { [k: string]: JsonValue; }; export type LogWriter = (message: string) => void; export type MessageContext = JsonObject & T; export type TopLevelAsyncLocalContext = { messageContext: MessageContext; transforms: ReadonlyArray>; }; type NestedAsyncLocalContext = TopLevelAsyncLocalContext & { sequence: number; sequenceRoot: string; }; export type AsyncLocalContext = | NestedAsyncLocalContext | TopLevelAsyncLocalContext; export type MessageSerializer = (message: Message) => string; export type RoarrGlobalState = { asyncLocalStorage?: AsyncLocalStorage; onceLog: Set; sequence: number; serializeMessage?: MessageSerializer; versions: readonly string[]; write: LogWriter; }; type SprintfArgument = boolean | number | string | null; export type Message = { readonly context: T; readonly message: string; readonly sequence: string; readonly time: number; readonly version: string; }; export type TransformMessageFunction = ( message: Message, ) => Message; type LogMethod = { ( context: Z, message: T, c?: T extends `${string}%${string}` ? SprintfArgument : never, d?: SprintfArgument, e?: SprintfArgument, f?: SprintfArgument, g?: SprintfArgument, h?: SprintfArgument, index?: SprintfArgument, index_?: SprintfArgument, ): void; ( message: T, b?: T extends `${string}%${string}` ? SprintfArgument : never, c?: SprintfArgument, d?: SprintfArgument, e?: SprintfArgument, f?: SprintfArgument, g?: SprintfArgument, h?: SprintfArgument, index?: SprintfArgument, index_?: SprintfArgument, ): void; }; type Child = { (context: TransformMessageFunction>): Logger; (context: MessageContext): Logger; }; export type Logger = LogMethod & { adopt: ( routine: () => T, context?: MessageContext | TransformMessageFunction, ) => Promise; child: Child; debug: LogMethod; debugOnce: LogMethod; error: LogMethod; errorOnce: LogMethod; fatal: LogMethod; fatalOnce: LogMethod; getContext: () => MessageContext; info: LogMethod; infoOnce: LogMethod; trace: LogMethod; traceOnce: LogMethod; warn: LogMethod; warnOnce: LogMethod; }; export type MessageEventHandler = (message: Message) => void; export type LogLevelName = | 'debug' | 'error' | 'fatal' | 'info' | 'trace' | 'warn';