@caeljs/logger
Version:
Simple log system for your node js application, supported colors.
1,023 lines (1,019 loc) • 29.1 kB
TypeScript
import { Console } from "console"
// Generated by dts-bundle-generator v9.5.1
/**
* Loggings class extends the built-in Console class and provides
* a structured logging system with plugin support.
*/
export declare class Loggings<const in out Plugins extends LoggingsPlugin<any>[] = typeof LoggingsDefaultPlugins> extends Console {
/**
* Global logging configuration.
*/
static configs: Record<string, any>;
/**
* Instance-specific logging configuration.
*/
configs: Omit<LoggingsConstructorConfig<Plugins>, "plugins">;
/**
* Get all instance configurations including plugins configurations
*/
get allconfigs(): any;
/**
* Get all Globals configurations including plugins configurations
*/
static get allconfigs(): any;
/**
* Default plugins applied globally.
*/
static plugins: LoggingsPlugin<any>[];
/**
* Instance-specific plugins.
*/
plugins: Plugins;
constructor(title?: string, color?: keyof typeof LoggingsPallet, advanced?: Partial<LoggingsBaseConfig> & {
plugins?: Plugins;
} & Partial<LoggingsPluginsConfig<Plugins>> & {
plugins?: typeof LoggingsDefaultPlugins;
});
constructor(advanced: Partial<LoggingsBaseConfig> & {
plugins?: Plugins;
} & Partial<LoggingsPluginsConfig<Plugins>> & {
plugins?: typeof LoggingsDefaultPlugins;
});
/**
* Loads plugins into the logging system.
*
* @param instance_plugins List of plugins to be loaded.
* @param nostatic Whether to skip static plugin loading.
* @returns Loaded plugin data.
*/
static pluginLoader<Plugins extends LoggingsPlugin<any>[]>(instance_plugins: Plugins, nostatic?: boolean): LoggingsPluginData<any>[];
/**
* Updates the logging configuration dynamically.
*
* @param advanced New configuration settings.
* @returns Updated Loggings instance.
*/
config<const NewPlugins extends LoggingsPlugin<any>[] = typeof LoggingsDefaultPlugins>(advanced?: Partial<LoggingsBaseConfig> & {
plugins?: NewPlugins;
} & Partial<LoggingsPluginsConfig<NewPlugins>>): Loggings<NewPlugins>;
/**
* Updates Global logging configuration dynamically.
*
* @param advanced New configuration settings.
* @returns Updated Loggings instance.
*/
static config<const NewPlugins extends LoggingsPlugin<any>[] = typeof LoggingsDefaultPlugins>(advanced?: Partial<LoggingsBaseConfig> & {
plugins?: NewPlugins;
} & Partial<LoggingsPluginsConfig<NewPlugins>>): Loggings<NewPlugins>;
/**
* Overrides the global console with the logging system.
*
* @param logger Logging instance to be used as console.
*/
static useConsole(logger: InstanceType<typeof Loggings>): void;
/**
* Controls message logging using the configured plugins.
*
* @param msgs Messages to be logged.
* @param level Log level.
*/
controller(msgs: LoggingsMessage[], level: LoggingsLevel): void;
/** Logging methods */
log(...messages: LoggingsMessage[]): this;
debug(...messages: LoggingsMessage[]): this;
error(...messages: LoggingsMessage[]): this;
trace(...messages: LoggingsMessage[]): this;
info(...messages: LoggingsMessage[]): this;
warn(...messages: LoggingsMessage[]): this;
txt(...messages: LoggingsMessage[]): this;
}
/**
* Colors
*/
export declare const Colors: typeof colorpik;
/**
* Loggings Console plugin
*
* Allow loggings show logs in terminal with colors
*
* @version 2.0.0
*/
export declare const ConsolePlugin: (opts?: LoggingsConsoleOptions) => LoggingsPluginData<LoggingsConsoleConfig & Partial<LoggingsBaseConfig>>;
/**
* Loggings Console Default options
*/
export declare const ConsolePluginDefault: LoggingsConsoleConfig;
/**
* Default Loggings Formatkits
*/
export declare const LOGGINGS_FORMATKITS: LoggingsFormatKitFunction[];
export declare const LoggingsAnsiSpecials: {
reset: string;
bold: string;
italic: string;
underline: string;
blink: string;
reverse: string;
hidden: string;
strikethrough: string;
none: string;
};
export declare const LoggingsCommonPallet: {
red: string;
green: string;
lime: string;
blue: string;
yellow: string;
cyan: string;
magenta: string;
black: string;
white: string;
gray: string;
maroon: string;
olive: string;
navy: string;
purple: string;
teal: string;
silver: string;
indigo: string;
gold: string;
pink: string;
orange: string;
brown: string;
peach: string;
lavender: string;
coral: string;
turquoise: string;
salmon: string;
olivebrab: string;
slate: string;
lsgreen: string;
dorange: string;
khaki: string;
mvred: string;
dsalmon: string;
lpink: string;
dgray: string;
gainsboro: string;
};
/**
* Default plugins used in the logging system.
*/
export declare const LoggingsDefaultPlugins: (((opts?: LoggingsConsoleOptions) => LoggingsPluginData<LoggingsConsoleConfig & Partial<LoggingsBaseConfig>>) | ((opts?: LoggingsRegisterOptions) => LoggingsPluginData<LoggingsRegisterConfig & Partial<LoggingsBaseConfig>>))[];
/**
* Loggings FormatKit Controller
*
* Processes text by applying the defined FormatKits, allowing logs to be styled
* with various formats such as colors, bold, underline, and gradients.
*
* @param texts - A string or an array of texts to be formatted.
* @param extraformats - Additional custom FormatKits.
* @param nocolor - Determines whether formatting should be disabled (returning plain text).
* @returns Returns a formatted string with applied styling rules.
* @since Loggings v3.0.0
* @new Fragment/Fragmenter of loggings
*
* @example
* ```ts
* const formatted = LoggingsFormatKitController("Text in *bold* and ~strikethrough~");
* console.log(formatted); // Output formatted with ANSI codes
* ```
*/
export declare const LoggingsFormatKitController: (texts: any | any[], extraformats?: LoggingsFormatKitFunction[], nocolor?: boolean) => string;
/**
* Creates a logging format function that applies a parser based on a regex or string
* and executes a callback to process the extracted values.
*
* @param {string | RegExp} parser - A regular expression or string to match patterns in the text.
* @param {(nocolor: boolean, ...text: string[]) => string} cb - Callback function to handle the extracted values.
* - `nocolor`: Indicates whether color formatting should be disabled.
* - `...text`: Captured groups from the regex applied to the input text.
* @returns {LoggingsFormatKitFunction} Returns a function that can be used to process formatted logs.
*
* @example
* const parser = LoggingsFormatParser(/\[([^\]]+)\]\.(\w+)(-b)?/, (nocolor, _, text, key, boldFlag) => {
* let result = boldFlag ? "**" : "";
* result += key.toUpperCase() + ": " + text;
* return result;
* });
*
* console.log(parser(false, "[hello].red")); // "RED: hello"
* console.log(parser(false, "[world].blue-b")); // "**BLUE: world"
*/
export declare const LoggingsFormatParser: (parser: string | RegExp, cb: (nocolor: boolean, ...text: string[]) => string) => LoggingsFormatKitFunction;
/**
* Returns Gradient Text in terminal colors
*
* @since Loggings v3.0.0
*/
export declare const LoggingsGrandient: (text: string) => string;
export declare const LoggingsPallet: {
slate5: "#f8fafc";
slate10: "#f1f5f9";
slate20: "#e2e8f0";
slate30: "#cbd5e1";
slate40: "#94a3b8";
slate50: "#64748b";
slate60: "#475569";
slate70: "#334155";
slate80: "#1e293b";
slate90: "#0f172a";
slate95: "#020617";
gray5: "#f9fafb";
gray10: "#f3f4f6";
gray20: "#e5e7eb";
gray30: "#d1d5db";
gray40: "#9ca3af";
gray50: "#6b7280";
gray60: "#4b5563";
gray70: "#374151";
gray80: "#1f2937";
gray90: "#111827";
gray95: "#030712";
zinc5: "#fafafa";
zinc10: "#f4f4f5";
zinc20: "#e4e4e7";
zinc30: "#d4d4d8";
zinc40: "#a1a1aa";
zinc50: "#71717a";
zinc60: "#52525b";
zinc70: "#3f3f46";
zinc80: "#27272a";
zinc90: "#18181b";
zinc95: "#09090b";
neutral5: "#fafafa";
neutral10: "#f5f5f5";
neutral20: "#e5e5e5";
neutral30: "#d4d4d4";
neutral40: "#a3a3a3";
neutral50: "#737373";
neutral60: "#525252";
neutral70: "#404040";
neutral80: "#262626";
neutral90: "#171717";
neutral95: "#0a0a0a";
stone5: "#fafaf9";
stone10: "#f5f5f4";
stone20: "#e7e5e4";
stone30: "#d6d3d1";
stone40: "#a8a29e";
stone50: "#78716c";
stone60: "#57534e";
stone70: "#44403c";
stone80: "#292524";
stone90: "#1c1917";
stone95: "#0c0a09";
red5: "#fef2f2";
red10: "#fee2e2";
red20: "#fecaca";
red30: "#fca5a5";
red40: "#f87171";
red50: "#ef4444";
red60: "#dc2626";
red70: "#b91c1c";
red80: "#991b1b";
red90: "#7f1d1d";
red95: "#450a0a";
orange5: "#fff7ed";
orange10: "#ffedd5";
orange20: "#fed7aa";
orange30: "#fdba74";
orange40: "#fb923c";
orange50: "#f97316";
orange60: "#ea580c";
orange70: "#c2410c";
orange80: "#9a3412";
orange90: "#7c2d12";
orange95: "#431407";
amber5: "#fffbeb";
amber10: "#fef3c7";
amber20: "#fde68a";
amber30: "#fcd34d";
amber40: "#fbbf24";
amber50: "#f59e0b";
amber60: "#d97706";
amber70: "#b45309";
amber80: "#92400e";
amber90: "#78350f";
amber95: "#451a03";
yellow5: "#fefce8";
yellow10: "#fef9c3";
yellow20: "#fef08a";
yellow30: "#fde047";
yellow40: "#facc15";
yellow50: "#eab308";
yellow60: "#ca8a04";
yellow70: "#a16207";
yellow80: "#854d0e";
yellow90: "#713f12";
yellow95: "#422006";
lime5: "#f7fee7";
lime10: "#ecfccb";
lime20: "#d9f99d";
lime30: "#bef264";
lime40: "#a3e635";
lime50: "#84cc16";
lime60: "#65a30d";
lime70: "#4d7c0f";
lime80: "#3f6212";
lime90: "#365314";
lime95: "#1a2e05";
green5: "#f0fdf4";
green10: "#dcfce7";
green20: "#bbf7d0";
green30: "#86efac";
green40: "#4ade80";
green50: "#22c55e";
green60: "#16a34a";
green70: "#15803d";
green80: "#166534";
green90: "#14532d";
green95: "#052e16";
emerald5: "#ecfdf5";
emerald10: "#d1fae5";
emerald20: "#a7f3d0";
emerald30: "#6ee7b7";
emerald40: "#34d399";
emerald50: "#10b981";
emerald60: "#059669";
emerald70: "#047857";
emerald80: "#065f46";
emerald90: "#064e3b";
emerald95: "#022c22";
teal5: "#f0fdfa";
teal10: "#ccfbf1";
teal20: "#99f6e4";
teal30: "#5eead4";
teal40: "#2dd4bf";
teal50: "#14b8a6";
teal60: "#0d9488";
teal70: "#0f766e";
teal80: "#115e59";
teal90: "#134e4a";
teal95: "#042f2e";
cyan5: "#ecfeff";
cyan10: "#cffafe";
cyan20: "#a5f3fc";
cyan30: "#67e8f9";
cyan40: "#22d3ee";
cyan50: "#06b6d4";
cyan60: "#0891b2";
cyan70: "#0e7490";
cyan80: "#155e75";
cyan90: "#164e63";
cyan95: "#083344";
sky5: "#f0f9ff";
sky10: "#e0f2fe";
sky20: "#bae6fd";
sky30: "#7dd3fc";
sky40: "#38bdf8";
sky50: "#0ea5e9";
sky60: "#0284c7";
sky70: "#0369a1";
sky80: "#075985";
sky90: "#0c4a6e";
sky95: "#082f49";
blue5: "#eff6ff";
blue10: "#dbeafe";
blue20: "#bfdbfe";
blue30: "#93c5fd";
blue40: "#60a5fa";
blue50: "#3b82f6";
blue60: "#2563eb";
blue70: "#1d4ed8";
blue80: "#1e40af";
blue90: "#1e3a8a";
blue95: "#172554";
indigo5: "#eef2ff";
indigo10: "#e0e7ff";
indigo20: "#c7d2fe";
indigo30: "#a5b4fc";
indigo40: "#818cf8";
indigo50: "#6366f1";
indigo60: "#4f46e5";
indigo70: "#4338ca";
indigo80: "#3730a3";
indigo90: "#312e81";
indigo95: "#1e1b4b";
violet5: "#f5f3ff";
violet10: "#ede9fe";
violet20: "#ddd6fe";
violet30: "#c4b5fd";
violet40: "#a78bfa";
violet50: "#8b5cf6";
violet60: "#7c3aed";
violet70: "#6d28d9";
violet80: "#5b21b6";
violet90: "#4c1d95";
violet95: "#2e1065";
purple5: "#faf5ff";
purple10: "#f3e8ff";
purple20: "#e9d5ff";
purple30: "#d8b4fe";
purple40: "#c084fc";
purple50: "#a855f7";
purple60: "#9333ea";
purple70: "#7e22ce";
purple80: "#6b21a8";
purple90: "#581c87";
purple95: "#3b0764";
fuchsia5: "#fdf4ff";
fuchsia10: "#fae8ff";
fuchsia20: "#f5d0fe";
fuchsia30: "#f0abfc";
fuchsia40: "#e879f9";
fuchsia50: "#d946ef";
fuchsia60: "#c026d3";
fuchsia70: "#a21caf";
fuchsia80: "#86198f";
fuchsia90: "#701a75";
fuchsia95: "#4a044e";
pink5: "#fdf2f8";
pink10: "#fce7f3";
pink20: "#fbcfe8";
pink30: "#f9a8d4";
pink40: "#f472b6";
pink50: "#ec4899";
pink60: "#db2777";
pink70: "#be185d";
pink80: "#9d174d";
pink90: "#831843";
pink95: "#500724";
rose5: "#fff1f2";
rose10: "#ffe4e6";
rose20: "#fecdd3";
rose30: "#fda4af";
rose40: "#fb7185";
rose50: "#f43f5e";
rose60: "#e11d48";
rose70: "#be123c";
rose80: "#9f1239";
rose90: "#881337";
rose95: "#4c0519";
reset: string;
bold: string;
italic: string;
underline: string;
blink: string;
reverse: string;
hidden: string;
strikethrough: string;
none: string;
red: string;
green: string;
lime: string;
blue: string;
yellow: string;
cyan: string;
magenta: string;
black: string;
white: string;
gray: string;
maroon: string;
olive: string;
navy: string;
purple: string;
teal: string;
silver: string;
indigo: string;
gold: string;
pink: string;
orange: string;
brown: string;
peach: string;
lavender: string;
coral: string;
turquoise: string;
salmon: string;
olivebrab: string;
slate: string;
lsgreen: string;
dorange: string;
khaki: string;
mvred: string;
dsalmon: string;
lpink: string;
dgray: string;
gainsboro: string;
};
/**
* Palette created with the shades supported by tailwind,
* but instead of using "color-num" use "colornum"
* @example "slate10" // equivalent slate-100
*/
export declare const LoggingsTailwindColors: {
readonly slate5: "#f8fafc";
readonly slate10: "#f1f5f9";
readonly slate20: "#e2e8f0";
readonly slate30: "#cbd5e1";
readonly slate40: "#94a3b8";
readonly slate50: "#64748b";
readonly slate60: "#475569";
readonly slate70: "#334155";
readonly slate80: "#1e293b";
readonly slate90: "#0f172a";
readonly slate95: "#020617";
readonly gray5: "#f9fafb";
readonly gray10: "#f3f4f6";
readonly gray20: "#e5e7eb";
readonly gray30: "#d1d5db";
readonly gray40: "#9ca3af";
readonly gray50: "#6b7280";
readonly gray60: "#4b5563";
readonly gray70: "#374151";
readonly gray80: "#1f2937";
readonly gray90: "#111827";
readonly gray95: "#030712";
readonly zinc5: "#fafafa";
readonly zinc10: "#f4f4f5";
readonly zinc20: "#e4e4e7";
readonly zinc30: "#d4d4d8";
readonly zinc40: "#a1a1aa";
readonly zinc50: "#71717a";
readonly zinc60: "#52525b";
readonly zinc70: "#3f3f46";
readonly zinc80: "#27272a";
readonly zinc90: "#18181b";
readonly zinc95: "#09090b";
readonly neutral5: "#fafafa";
readonly neutral10: "#f5f5f5";
readonly neutral20: "#e5e5e5";
readonly neutral30: "#d4d4d4";
readonly neutral40: "#a3a3a3";
readonly neutral50: "#737373";
readonly neutral60: "#525252";
readonly neutral70: "#404040";
readonly neutral80: "#262626";
readonly neutral90: "#171717";
readonly neutral95: "#0a0a0a";
readonly stone5: "#fafaf9";
readonly stone10: "#f5f5f4";
readonly stone20: "#e7e5e4";
readonly stone30: "#d6d3d1";
readonly stone40: "#a8a29e";
readonly stone50: "#78716c";
readonly stone60: "#57534e";
readonly stone70: "#44403c";
readonly stone80: "#292524";
readonly stone90: "#1c1917";
readonly stone95: "#0c0a09";
readonly red5: "#fef2f2";
readonly red10: "#fee2e2";
readonly red20: "#fecaca";
readonly red30: "#fca5a5";
readonly red40: "#f87171";
readonly red50: "#ef4444";
readonly red60: "#dc2626";
readonly red70: "#b91c1c";
readonly red80: "#991b1b";
readonly red90: "#7f1d1d";
readonly red95: "#450a0a";
readonly orange5: "#fff7ed";
readonly orange10: "#ffedd5";
readonly orange20: "#fed7aa";
readonly orange30: "#fdba74";
readonly orange40: "#fb923c";
readonly orange50: "#f97316";
readonly orange60: "#ea580c";
readonly orange70: "#c2410c";
readonly orange80: "#9a3412";
readonly orange90: "#7c2d12";
readonly orange95: "#431407";
readonly amber5: "#fffbeb";
readonly amber10: "#fef3c7";
readonly amber20: "#fde68a";
readonly amber30: "#fcd34d";
readonly amber40: "#fbbf24";
readonly amber50: "#f59e0b";
readonly amber60: "#d97706";
readonly amber70: "#b45309";
readonly amber80: "#92400e";
readonly amber90: "#78350f";
readonly amber95: "#451a03";
readonly yellow5: "#fefce8";
readonly yellow10: "#fef9c3";
readonly yellow20: "#fef08a";
readonly yellow30: "#fde047";
readonly yellow40: "#facc15";
readonly yellow50: "#eab308";
readonly yellow60: "#ca8a04";
readonly yellow70: "#a16207";
readonly yellow80: "#854d0e";
readonly yellow90: "#713f12";
readonly yellow95: "#422006";
readonly lime5: "#f7fee7";
readonly lime10: "#ecfccb";
readonly lime20: "#d9f99d";
readonly lime30: "#bef264";
readonly lime40: "#a3e635";
readonly lime50: "#84cc16";
readonly lime60: "#65a30d";
readonly lime70: "#4d7c0f";
readonly lime80: "#3f6212";
readonly lime90: "#365314";
readonly lime95: "#1a2e05";
readonly green5: "#f0fdf4";
readonly green10: "#dcfce7";
readonly green20: "#bbf7d0";
readonly green30: "#86efac";
readonly green40: "#4ade80";
readonly green50: "#22c55e";
readonly green60: "#16a34a";
readonly green70: "#15803d";
readonly green80: "#166534";
readonly green90: "#14532d";
readonly green95: "#052e16";
readonly emerald5: "#ecfdf5";
readonly emerald10: "#d1fae5";
readonly emerald20: "#a7f3d0";
readonly emerald30: "#6ee7b7";
readonly emerald40: "#34d399";
readonly emerald50: "#10b981";
readonly emerald60: "#059669";
readonly emerald70: "#047857";
readonly emerald80: "#065f46";
readonly emerald90: "#064e3b";
readonly emerald95: "#022c22";
readonly teal5: "#f0fdfa";
readonly teal10: "#ccfbf1";
readonly teal20: "#99f6e4";
readonly teal30: "#5eead4";
readonly teal40: "#2dd4bf";
readonly teal50: "#14b8a6";
readonly teal60: "#0d9488";
readonly teal70: "#0f766e";
readonly teal80: "#115e59";
readonly teal90: "#134e4a";
readonly teal95: "#042f2e";
readonly cyan5: "#ecfeff";
readonly cyan10: "#cffafe";
readonly cyan20: "#a5f3fc";
readonly cyan30: "#67e8f9";
readonly cyan40: "#22d3ee";
readonly cyan50: "#06b6d4";
readonly cyan60: "#0891b2";
readonly cyan70: "#0e7490";
readonly cyan80: "#155e75";
readonly cyan90: "#164e63";
readonly cyan95: "#083344";
readonly sky5: "#f0f9ff";
readonly sky10: "#e0f2fe";
readonly sky20: "#bae6fd";
readonly sky30: "#7dd3fc";
readonly sky40: "#38bdf8";
readonly sky50: "#0ea5e9";
readonly sky60: "#0284c7";
readonly sky70: "#0369a1";
readonly sky80: "#075985";
readonly sky90: "#0c4a6e";
readonly sky95: "#082f49";
readonly blue5: "#eff6ff";
readonly blue10: "#dbeafe";
readonly blue20: "#bfdbfe";
readonly blue30: "#93c5fd";
readonly blue40: "#60a5fa";
readonly blue50: "#3b82f6";
readonly blue60: "#2563eb";
readonly blue70: "#1d4ed8";
readonly blue80: "#1e40af";
readonly blue90: "#1e3a8a";
readonly blue95: "#172554";
readonly indigo5: "#eef2ff";
readonly indigo10: "#e0e7ff";
readonly indigo20: "#c7d2fe";
readonly indigo30: "#a5b4fc";
readonly indigo40: "#818cf8";
readonly indigo50: "#6366f1";
readonly indigo60: "#4f46e5";
readonly indigo70: "#4338ca";
readonly indigo80: "#3730a3";
readonly indigo90: "#312e81";
readonly indigo95: "#1e1b4b";
readonly violet5: "#f5f3ff";
readonly violet10: "#ede9fe";
readonly violet20: "#ddd6fe";
readonly violet30: "#c4b5fd";
readonly violet40: "#a78bfa";
readonly violet50: "#8b5cf6";
readonly violet60: "#7c3aed";
readonly violet70: "#6d28d9";
readonly violet80: "#5b21b6";
readonly violet90: "#4c1d95";
readonly violet95: "#2e1065";
readonly purple5: "#faf5ff";
readonly purple10: "#f3e8ff";
readonly purple20: "#e9d5ff";
readonly purple30: "#d8b4fe";
readonly purple40: "#c084fc";
readonly purple50: "#a855f7";
readonly purple60: "#9333ea";
readonly purple70: "#7e22ce";
readonly purple80: "#6b21a8";
readonly purple90: "#581c87";
readonly purple95: "#3b0764";
readonly fuchsia5: "#fdf4ff";
readonly fuchsia10: "#fae8ff";
readonly fuchsia20: "#f5d0fe";
readonly fuchsia30: "#f0abfc";
readonly fuchsia40: "#e879f9";
readonly fuchsia50: "#d946ef";
readonly fuchsia60: "#c026d3";
readonly fuchsia70: "#a21caf";
readonly fuchsia80: "#86198f";
readonly fuchsia90: "#701a75";
readonly fuchsia95: "#4a044e";
readonly pink5: "#fdf2f8";
readonly pink10: "#fce7f3";
readonly pink20: "#fbcfe8";
readonly pink30: "#f9a8d4";
readonly pink40: "#f472b6";
readonly pink50: "#ec4899";
readonly pink60: "#db2777";
readonly pink70: "#be185d";
readonly pink80: "#9d174d";
readonly pink90: "#831843";
readonly pink95: "#500724";
readonly rose5: "#fff1f2";
readonly rose10: "#ffe4e6";
readonly rose20: "#fecdd3";
readonly rose30: "#fda4af";
readonly rose40: "#fb7185";
readonly rose50: "#f43f5e";
readonly rose60: "#e11d48";
readonly rose70: "#be123c";
readonly rose80: "#9f1239";
readonly rose90: "#881337";
readonly rose95: "#4c0519";
};
/**
* Loggings Register plugin
*
* Allow loggings show logs in terminal with colors
*
* @version 2.0.0
*/
export declare const RegisterPlugin: (opts?: LoggingsRegisterOptions) => LoggingsPluginData<LoggingsRegisterConfig & Partial<LoggingsBaseConfig>>;
/**
* Loggings Register Default options
*/
export declare const RegisterPluginDefault: LoggingsRegisterConfig;
/**
* Text RGB Color
* @param r Red color (0 ~ 255)
* @param g Green color (0 ~ 255)
* @param b Blue color (0 ~ 255)
* @returns (isBackground? = false) => string // terminal string
*/
export declare const rgb: (r: number, g: number, b: number) => (bg?: boolean) => string;
/**
* Convert Hexadecimal to terminal colors
* @example termcolor("#FFFFFF") // text terminal color
* @example termcolor("\x1b[4m") // return "\x1b[4m"
* @example termcolor("slate5", true) // background terminal color
* @example termcolor("slate-50") // equivalent "slate5" text terminal color
* @example termcolor(2553641265); rgb(255, 0, 0)() // equivalent "slate5" text terminal color
*/
export declare const termcolor: (color: string | number, background?: boolean) => string;
/**
* Loggings convert hex to hexadecimal number
*/
export declare const toHexadecimal: (color: string | number) => number;
export declare enum Runtime {
Node = 0,
Bun = 1,
Deno = 2,
Browser = 3
}
export declare function LoggingsLevelToNumber(level: LoggingsLevel): 1 | 2 | 3 | 4;
export declare function colorpik(key: string, text: string, extra?: Record<string, string>): string;
export declare function timer(format: string): {
format: string;
timer: TimerFormat;
};
/**
* Current Runtime
*/
export declare let runtime: Runtime;
export type EnsureLoggingsPlugins<T extends LoggingsPlugin<any>[]> = T extends [
] ? LoggingsPlugin<any>[] : {
[K in keyof T]: T[K] extends () => infer R ? R : T[K];
};
export type LoggingsBaseConfig = {
/**
* Global Level of show and write logs
* Supported Levels: "error" | "warn" | "info" | "debug"
* @default "info"
*/
level: LoggingsLevel;
/**
* Title of logger
*
* @since Loggings v1.0.0
*/
title: string;
/**
* Loggings FormatKits
*
* FormatKits define how Loggings processes color and style formatting in logs.
* This is an advanced technology that enables even more flexible customization,
* allowing log texts to be dynamically transformed and personalized.
*
* ⚠️ **Advanced Feature**: Do not modify this parameter unless you know exactly what you are doing.
*
* @since Loggings v3.0.0
* @default
* ```ts
* import Loggings, { LoggingsPallet } from "loggings";
* const logger = new Loggings();
* logger.config({
* formatKits: [
* (nocolor, text) => LoggingsPallet.strikethrough + text + LoggingsPallet.reset,
* ]
* });
* logger.log("This is ~not~ funny");
* ```
*/
formatKits: LoggingsFormatKitFunction[];
};
export type LoggingsConsoleConfig = {
/**
* Format log Message, Console print.
*
* Main Args: {status} | {message} | {title}
*
* Timer Args: {day} | {month} | {year} | {hours} | {minutes}| {seconds} | {milliseconds}
*
* @default "[{status}] [{{hours}:{minutes}:{seconds}}].gray {message}"
*/
format: string;
/**
* Loggings Level
* Console-specific level will be used
*/
console_level?: LoggingsLevel;
/**
* Status colors
*/
status: Record<LoggingsLevel, keyof typeof LoggingsPallet>;
/**
* Add new Colors code(ansi or rgb code colors), used in logs functions,
* e.g:
* @default ```ts
* import Loggings, { rgb } from "loggings";
* const logger = new Loggings();
* logger.config({
* colors: {
* "ngreen": rgb(57, 255, 20)() // Neon Green
* }
* })
* logger.log("[Hello].ngreen")
* ```
*/
colors?: Record<string, string>;
/**
* If any color using the [].color declaration is wrong,
* we will use that color instead.
*/
fallback: keyof typeof LoggingsPallet;
/**
* In some types of hosting, the terminal does not support
* ansi colors or uses the terminal to display logs.
* The loggings module uses arguments that apply colors to the terminal
* using ansi codes, which can make logs difficult to read when saved in
* .txt files due to the presence of several random characters.
*
* To solve this problem, this boolean has been added, that,
* when activated, causes the loggings module to ignore the color codes
* and imprint simple logs on the terminal, without color formatting.
*
* Hosts that this boolean becomes useful:
* [Discloud, Squarecloud]
*/
disable_colors: boolean;
/**
* Allows show logs in terminal
*/
console: boolean;
/**
* Color of title
*/
color: keyof typeof LoggingsPallet;
};
export type LoggingsConsoleOptions = {
onPreMessage?: LoggingsPluginData<LoggingsConsoleConfig>["onPreMessage"];
onMessage?: LoggingsPluginData<LoggingsConsoleConfig>["onMessage"];
onSend?: LoggingsPluginData<LoggingsConsoleConfig>["onSend"];
onInit?: LoggingsPluginData<LoggingsConsoleConfig>["onInit"];
};
export type LoggingsConstructorConfig<Plugins extends LoggingsPlugin<any>[] = [
]> = {
/**
* Loggings plugins
* @default [ConsolePlugin, RegisterPlugin]
*/
plugins: Plugins;
} & LoggingsBaseConfig & Partial<LoggingsPluginsConfig<EnsureLoggingsPlugins<Plugins>>>;
export type LoggingsFormatKitFunction = (nocolor: boolean, input: string) => string;
/**
* Supported levels of loggings
*/
export type LoggingsLevel = "info" | "debug" | "warn" | "trace" | "error" | "txt";
export type LoggingsMessage = string | boolean | object | number | undefined | null | Symbol;
export type LoggingsPlugin<T extends object> = LoggingsPluginData<T> | (() => LoggingsPluginData<T>);
export type LoggingsPluginData<PluginConfig extends object> = {
ident: string;
default: PluginConfig;
onInit?(config: PluginConfig): unknown;
onPreMessage?(config: PluginConfig, level: LoggingsLevel, messages: LoggingsMessage[]): LoggingsMessage[] | undefined;
onMessage?(config: PluginConfig, level: LoggingsLevel, messages: LoggingsMessage[]): string;
onSend?(config: PluginConfig, level: LoggingsLevel, message: string): unknown;
onError?(config: PluginConfig, error: Error): unknown;
};
export type LoggingsPluginsConfig<Plugins extends LoggingsPlugin<any>[] = [
]> = Plugins extends [
] ? {} : UnionToIntersection<{
[K in keyof Plugins]: Plugins[K] extends () => LoggingsPluginData<infer T> ? T : Plugins[K] extends LoggingsPluginData<infer T> ? T : {};
}[number]>;
export type LoggingsPluginsConfiguration<Plugins extends LoggingsPlugin<any>[]> = Partial<LoggingsBaseConfig> & {
plugins?: Plugins;
} & Partial<LoggingsPluginsConfig<Plugins>> & {
plugins?: Plugins;
};
export type LoggingsRegisterConfig = {
/**
* Allows register logs in file, on {register_dir}
*/
register: boolean;
/**
* Allows you to delete the logs, if you exceed the limit configured
* in "register_limit", if "register_limit" is 0, it will be ignored
*/
register_del: boolean;
/**
* Loggings Level
* Register-specific level will be used
*/
register_level?: LoggingsLevel;
/**
* Sets how many log files will be needed to start deleting old files,
* if "register_del" is disabled or the value set is 0,
* this option will be ignored
*/
register_limit: number;
/**
* Directory where the files will be stored, if "register" is disabled, it will be ignored
*/
register_dir: string;
/**
* Register Format locale file.
*
* Suported Args: {register_dir} | {status} | {title}
*
* @default "{register_dir}/{status}"
*/
register_locale_file: string;
/**
* Register File Format locale file.
*
* Main Args: {ext} | {status}
*
* Timer Args: {day} | {month} | {year} | {hours} | {minutes}| {seconds} | {milliseconds}
*
* @default "{day}_{month}_{year}.{ext}"
*/
register_filename: string;
/**
* Register Format, in registration logs,
*
* Main Args: {status} | {message} | {title}
*
* Timer Args: {day} | {month} | {year} | {hours} | {minutes}| {seconds} | {milliseconds}
*
* @default "[ {day}/{month}/{year} in {hours}:{minutes}:{seconds} ] [ _.{title}._ ]{message}"
*/
register_format: string;
};
export type LoggingsRegisterOptions = {
onPreMessage?: LoggingsPluginData<LoggingsRegisterConfig>["onPreMessage"];
onMessage?: LoggingsPluginData<LoggingsRegisterConfig>["onMessage"];
onSend?: LoggingsPluginData<LoggingsRegisterConfig>["onSend"];
onInit?: LoggingsPluginData<LoggingsRegisterConfig>["onInit"];
};
/**
* Timer Format
*/
export type TimerFormat = {
timestamp: number;
year: string;
month: string;
day: string;
hours: string;
minutes: string;
seconds: string;
milliseconds: string;
};
export type UnionToIntersection<U> = (U extends any ? (x: U) => void : {}) extends (x: infer I) => void ? I : {};
export {
Loggings as default,
};
export {};