import type { LogStatus } from './squared'; import type { LOG_TYPE, STATUS_TYPE } from '../index.d'; import type { BackgroundColor as IBackgroundColor, ForegroundColor as IForegroundColor } from 'chalk'; type HexColor = `#${string}`; export interface LogBaseOptions extends LoggerColor, Pick { type?: LogType; statusType?: StatusType; sessionId?: string; abortable?: boolean; titleJustify?: TextAlign; broadcastId?: BroadcastValue; newline?: boolean | number; } export interface LoggerColor { titleColor?: ForegroundColor; titleBgColor?: BackgroundColor; titleBold?: boolean; valueColor?: ForegroundColor; valueBgColor?: BackgroundColor; valueBold?: boolean; hintColor?: ForegroundColor; hintBgColor?: BackgroundColor; hintBold?: boolean; messageColor?: ForegroundColor; messageBgColor?: BackgroundColor; messageBold?: boolean; } export interface LoggerFormat { width?: T; color?: ForegroundColor; bg_color?: BackgroundColor; bg_alt_color?: BackgroundColor; bold?: boolean; justify?: TextAlign; unit?: string; as?: StringMap; } export interface LoggerStatus { fatal?: T; error?: T; warn?: T; info?: T; debug?: T; trace?: T; } export interface LogOptions extends Partial, "duration" | "from" | "source">> { queue?: boolean; timeStamp?: LogDate; } export interface LogMessageOptions extends LogBaseOptions { failed?: boolean; useColor?: boolean; messageWidth?: number; messageUnit?: string; messageUnitMinWidth?: number; messageUnitIndent?: number | [number, string]; progressBar?: boolean; alwaysVisible?: boolean; titleIndent?: boolean | number; } export interface LogFailOptions extends LogBaseOptions { exec?: ExecCommand; code?: string; fatal?: boolean; passThrough?: boolean; startTime?: LogTime; } export interface LogProcessOptions extends LogMessageOptions { bypassLog?: boolean; meterIncrement?: number; delayTime?: number | HighResolutionTime; } export interface LogTimeElapsedOptions extends LogMessageOptions { showCpu?: boolean; } export interface LogTypeValue { type: LogType; value: LogValue; timeStamp: number; sessionId?: string; } export interface LogArguments extends Pick { title?: string; value?: LogValue; message?: unknown; } export interface ExecCommand { command: string; args?: string[]; warn?: string[]; } export type { LOG_TYPE, STATUS_TYPE }; export type LogType = LOG_TYPE[keyof LOG_TYPE]; export type StatusType = STATUS_TYPE[keyof STATUS_TYPE]; export type StatusName = keyof typeof STATUS_TYPE; export type LogDate = Date | number; export type LogTime = LogDate | HighResolutionTime; export type LogValue = string | [string, Null?]; export type LogComponent = Partial, "type" | "value" | "timeStamp" | "duration" | "from" | "source">>; export type BackgroundColor = typeof IBackgroundColor | HexColor; export type ForegroundColor = typeof IForegroundColor | HexColor; export type TextAlign = "left" | "center" | "right"; export type ErrorOutMethod = (err: Error, data: LogTypeValue, require?: NodeRequire) => void; export type BroadcastOutMethod = (value: string, options: LogMessageOptions, require?: NodeRequire) => void; export type BroadcastValue = StringOfArray | { value: StringOfArray; stripAnsi?: boolean };