UNPKG

logsdx

Version:

<div align="center"><img alt="logsdx" width="300" src="https://github.com/user-attachments/assets/cc2a3b55-5bfd-44e8-a330-bfa146b50059" /></div>

85 lines (84 loc) 4.11 kB
import { renderLine } from "./renderer"; import { getTheme, getThemeAsync, getAllThemes, getThemeNames, preloadTheme, preloadAllThemes, registerTheme, registerThemeLoader, ThemeBuilder, createTheme, createSimpleTheme, extendTheme, THEME_PRESETS } from "./themes"; import { validateTheme, validateThemeSafe } from "./schema/validator"; import { tokenize, applyTheme } from "./tokenizer"; import type { TokenList } from "./schema/types"; import type { LineParser, ParsedLine, StyleOptions, Theme, ThemePair, LogsDXOptions } from "./types"; import { renderLightBox, renderLightBoxLine, isLightTheme as isLightThemeRenderer } from "./renderer"; /** * LogsDX - A powerful log processing and styling tool * * This class provides a singleton instance for processing and styling log files * with customizable themes and output formats. * * @example * ```typescript * const logsdx = LogsDX.getInstance({ theme: 'dracula' }); * const styledLog = logsdx.processLine('[INFO] Application started'); * console.log(styledLog); * ``` */ export declare class LogsDX { private static instance; private static instancePromise; private options; private currentTheme; private constructor(); private resolveTheme; /** * Get or create the singleton LogsDX instance * * @param options - Configuration options for LogsDX * @param options.theme - Theme name, Theme object, or ThemePair to use * @param options.outputFormat - Output format: 'ansi' (default) or 'html' * @param options.htmlStyleFormat - HTML style format: 'css' (inline styles) or 'className' * @param options.escapeHtml - Whether to escape HTML in output (default: true) * @param options.debug - Enable debug logging (default: false) * @param options.autoAdjustTerminal - Auto-adjust theme based on terminal background (default: true) * @returns The LogsDX singleton instance * * @example * ```typescript * const logsdx = await LogsDX.getInstance({ theme: 'nord', outputFormat: 'ansi' }); * ``` */ static getInstance(options?: LogsDXOptions): Promise<LogsDX>; /** * Reset the LogsDX singleton instance * * Useful for testing or when you need to reconfigure LogsDX from scratch */ static resetInstance(): void; /** * Process a single log line with the current theme and styling * * @param line - The log line to process * @returns The styled log line as a string * * @example * ```typescript * const logsdx = LogsDX.getInstance({ theme: 'dracula' }); * const styled = logsdx.processLine('[ERROR] Connection timeout'); * console.log(styled); // Output with Dracula theme styling * ``` */ processLine(line: string): string; processLines(lines: string[]): string[]; processLog(logContent: string): string; tokenizeLine(line: string): TokenList; setTheme(theme: string | Theme | ThemePair): Promise<boolean>; getCurrentTheme(): Theme; getAllThemes(): Record<string, Theme>; getThemeNames(): string[]; setOutputFormat(format: "ansi" | "html"): void; setHtmlStyleFormat(format: "css" | "className"): void; getCurrentOutputFormat(): "ansi" | "html"; getCurrentHtmlStyleFormat(): "css" | "className"; } export declare function getLogsDX(options?: LogsDXOptions): Promise<LogsDX>; export type { Theme, ThemePair, StyleOptions, TokenList, LineParser, ParsedLine, }; export { getTheme, getThemeAsync, getAllThemes, getThemeNames, preloadTheme, preloadAllThemes, registerTheme, registerThemeLoader, validateTheme, validateThemeSafe, ThemeBuilder, createTheme, createSimpleTheme, extendTheme, THEME_PRESETS, }; export { tokenize, applyTheme }; export { renderLine, renderLightBox, renderLightBoxLine, isLightThemeRenderer as isLightThemeStyle, }; export { detectBackground, detectTerminalBackground, detectBrowserBackground, detectSystemBackground, isDarkBackground, isLightBackground, getRecommendedThemeMode, watchBackgroundChanges, type BackgroundInfo, type ColorScheme, } from "./renderer"; export default LogsDX;