UNPKG

@sprucelabs/spruce-skill-utils

Version:

Loosely coupled classes and functions to make skill development faster! 🏎

28 lines (27 loc) 1.07 kB
import chalk from 'chalk'; export interface LogOptions { log?: (...args: any[]) => void; useColors?: boolean; transportsByLevel?: Partial<TransportMap>; colors?: { info?: Color; error?: Color; }; } export type Level = 'ERROR' | 'INFO' | 'WARN'; export type LogTransport = (...messageParts: string[]) => void; type TransportMap = Record<Level, LogTransport | LogTransport[] | null | undefined>; type Anything = string | number | boolean | null | undefined | Error | unknown; export type LoggableType = Anything | Anything[] | Record<string, Anything>; export interface Log { readonly prefix: string | undefined; info: (...args: LoggableType[]) => string; error: (...args: LoggableType[]) => string; warn: (...args: LoggableType[]) => string; buildLog(prefix: string | undefined, options?: LogOptions): Log; } type Color = keyof typeof chalk; export default function buildLog(prefix?: string | undefined, options?: LogOptions): Log; export declare const testLog: Log; export declare const stubLog: Log; export {};