import { ConfigSchema, DisplayOptions, TargetType } from "./Configuration"; import { FuncFileLine, StackLineParser } from "./StackLineParser"; export declare function createLogFileWriter(name: string, filePath: string): LogWriter; /** * Returns the set of established categories as defined in configuration. */ export declare function getCategories(): string[]; /** * Adds a new category to the set of known categories * @param category */ export declare function addCategory(category: string): void; /** * Removes a category from the set of known categories * @param category */ export declare function removeCategory(category: string): void; /** * Loads the logger configuration JSON from the given path and sets the configuration. * This establishes the loggers and output writers, as well as category and level * definitions, color settings, and output formats to use. * See the documentation section on Configuration for more information. * * Available in Node settings. For browser-based contexts, load your config * via a script or AJAX operation and call `setLoggerConfig` rather than use this method. * * @throws Error if Node is not available or file is not found at path. * * @param path */ export declare function loadLoggerConfig(path: string): void; /** * Sets the configuration from a JSON text string. * If you've loaded a parsed script, or have constructed a JS object, * call `setLoggerConfig` instead. * @param json */ export declare function setLoggerConfigJSON(json: string): void; /** * Creates and returns a default logger suitable for general console purposes * It has a single writer ('Console') that outputs in color. */ export declare function createDefaultLogger(): Logger; /** * Creates and returns a logger that does not use color. * It has a single writer ('Console') that outputs plain text * with no timestamp and a category/level/function start to each line */ export declare function createMonochromeLogger(): Logger; /** * Use to set the Logger configuration from an object resolved from JSON or * constructed dynamically. * Use in browser-based contexts, since `loadLoggerConfig` in unavailable without Node support. * This establishes the loggers and output writers, as well as category and level * definitions, color settings, and output formats to use. * See the documentation section on Configuration for more information. * @param config */ export declare function setLoggerConfig(config: ConfigSchema): void; /** * Return a configured Logger by name * @param name */ export declare function getLogger(name: string): any; /** * Read the accumulated text in the named memory log. * Note that the name of a Memory log is established with the 'memoryName' property of * the writer configuration, or the name of the writer itself if no 'memoryName' is provided. * See the section on Configuration for more info. * * @param name */ export declare function readMemoryLog(name: string): any; /** * Clears the memory buffer text for this Memory log. * @param name */ export declare function clearMemoryLog(name: string): void; /** * The writer output callback for custom writers */ interface LogWriterOutput { outputLogToDestination?: (location: string, formatted: string, category: string, level: string, stack: string | null, xargs: any[] | null) => void; } /** * A target names the target type and location */ export declare class LogTarget implements LogWriterOutput { name: string; type: TargetType | string; location?: string; supportsColor?: boolean; colorCategories?: any; colorLevels?: any; state?: any; displayOptions: DisplayOptions; constructor(name: string, type: TargetType | string, location?: string, color?: boolean); outputLogToDestination(location: string, formatted: string, category: string, level: string, stack: string | null, xargs: any[] | null): void; } /** * Defines where the output will appear, and what categories/levels are filtered */ export declare class LogWriter { target: LogTarget; private categoryExcludes; private levelExcludes; constructor(target: LogTarget); includeCategory(category: string, ...more: string[]): void; excludeCategory(category: string, ...more: string[]): void; includeLevel(level: string, ...more: string[]): void; excludeLevel(level: string, ...more: string[]): void; clearLevelExclusions(): void; clearCategoryExclusions(): void; isCategoryExcluded(category: string): boolean; isLevelExcluded(level: string): boolean; outputLog(formatted: string, category: string, level: string, stack: string | null, xargs: any[] | null): void; startGroup(indent: number, groupName: string): void; endGroup(indent: number, groupName: string): void; /** * Returns the colors to use per display item for a given category and level * @param category * @param level * @returns Object containing color info */ private getColors; /** * Support output as JSON */ composeJSON(time: number, category: string, level: string, ffl: FuncFileLine, fmesg: string, stackdump: string): string; /** * Format the log output */ logFormat(time: number, category: string, level: string, ffl: FuncFileLine, stackParser: StackLineParser, message: string, ...args: any[]): { out: string; xargs: any; stackdump: any; }; } export declare class Logger { private writers; private groups; private stackParser; private defaultCategoryName; private currentDefaultLevel; /** * return the array of writers attached to this logger */ getWriters(): LogWriter[]; /** * Add a new writer to this logger * @param writer */ addWriter(writer: LogWriter): void; /** * Remove a writer from this logger * @param writer */ removeWriter(writer: LogWriter): void; /** * Find a writer by name that belongs to this Logger * @param targetName */ findWriter(targetName: string): LogWriter | null; /** * Set the name of a category to appear by default * @param defName * @returns - previously set name (so we can put it back if this is a temporary labelling) */ setDefaultCategoryName(defName: string): string; /** * Include all the levels in the writer output * @param writerName - name of writer to affect */ includeAllLevels(writerName: string): void; /** * Exclude all levels from the writer output * @param writerName - name of writer to affect */ excludeAllLevels(writerName: string): void; /** * Include a level for the named writer to output * * @param writerName - name of writer to affect * @param level - name of level. note that granular levels are not supported. Only primary level names. */ includeLevel(writerName: string, level: string): void; /** * Exclude a level for the named writer. * The writer will ignore all logs for this level * * @param writerName - name of writer to affect * @param level - name of level. note that granular levels are not supported. Only primary level names. */ excludeLevel(writerName: string, level: string): void; /** * Set a minimum level. * This level and above will be output by the writer. * levels below this will be excluded. * * @param writerName - name of writer to affect * @param minLevel - name of level. note that granular levels are not supported. Only primary level names. */ setMinimumLevel(writerName: string, minLevel: string): void; /** * Alternative to `setMinimumLevel` that targets the 'Console' writer, * remembers the setting, and returns the previous value. * Note that the remembered value is not affected by changes made by * calling `setMinimumLevel` directly. * @param minLevel - level to set * @return previousLevel - name of the previous level that was set via this mechanism */ changeDefaultLevel(minLevel: string): string; /** * turn color support on/off for a given writer * @param writerName * @param enabled */ enableColor(writerName: string, enabled: boolean): void; /** * Include all the categories in the writer output * @param writerName - name of writer to affect */ includeAllCategories(writerName: string): void; /** * Exclude all levels from the writer output * @param writerName - name of writer to affect */ excludeAllCategories(writerName: string): void; /** * Include a category for the named writer to output * * @param writerName - name of writer to affect * @param category - name of category. */ includeCategory(writerName: string, level: string): void; /** * Exclude a category for the named writer. * This writer will ignore logs in this category. * * @param writerName - name of writer to affect * @param category -- name of category */ excludeCategory(writerName: string, category: string): void; /** * Private method that converts a string 'level' (e.g. 'info', 'debug3', etc) * into the corresponding type (number) and suffix granularity. * @param level * @returns {{type, granularity}) (both properties are integers) * @private */ _levelToType(level?: string): { type: any; granularity: number; }; /** * Direct output to all writers, subject to filtering. * @param {number} time in milliseconds * @param {{file, func, line, stack}} ffl * @param {string} category * @param {string} level * @param {string} message * @param {*} args arguments used for formatting message */ outToWriters(time: number, ffl: FuncFileLine, category: string, level: string, message: string, ...args: any[]): void; /** * Handles passing category, message, args or simply message, args for any log level. * @param level * @param args * @private */ _morph(level: string, ...args: any[]): void; /** Outputs log at the named level granularity */ trace9(...args: any[]): void; /** Outputs log at the named level granularity */ trace8(...args: any[]): void; /** Outputs log at the named level granularity */ trace7(...args: any[]): void; /** Outputs log at the named level granularity */ trace6(...args: any[]): void; /** Outputs log at the named level granularity */ trace5(...args: any[]): void; /** Outputs log at the named level granularity */ trace4(...args: any[]): void; /** Outputs log at the named level granularity */ trace3(...args: any[]): void; /** Outputs log at the named level granularity */ trace2(...args: any[]): void; /** Outputs log at the named level granularity */ trace1(...args: any[]): void; /** Outputs log at the named level granularity */ trace0(...args: any[]): void; /** Synonymous with trace0 */ trace(...args: any[]): void; /** Outputs log at the named level granularity */ debug9(...args: any[]): void; /** Outputs log at the named level granularity */ debug8(...args: any[]): void; /** Outputs log at the named level granularity */ debug7(...args: any[]): void; /** Outputs log at the named level granularity */ debug6(...args: any[]): void; /** Outputs log at the named level granularity */ debug5(...args: any[]): void; /** Outputs log at the named level granularity */ debug4(...args: any[]): void; /** Outputs log at the named level granularity */ debug3(...args: any[]): void; /** Outputs log at the named level granularity */ debug2(...args: any[]): void; /** Outputs log at the named level granularity */ debug1(...args: any[]): void; /** Outputs log at the named level granularity */ debug0(...args: any[]): void; /** Synonymous with debug0 */ debug(...args: any[]): void; /** Outputs log at the named level granularity */ log9(...args: any[]): void; /** Outputs log at the named level granularity */ log8(...args: any[]): void; /** Outputs log at the named level granularity */ log7(...args: any[]): void; /** Outputs log at the named level granularity */ log6(...args: any[]): void; /** Outputs log at the named level granularity */ log5(...args: any[]): void; /** Outputs log at the named level granularity */ log4(...args: any[]): void; /** Outputs log at the named level granularity */ log3(...args: any[]): void; /** Outputs log at the named level granularity */ log2(...args: any[]): void; /** Outputs log at the named level granularity */ log1(...args: any[]): void; /** Outputs log at the named level granularity */ log0(...args: any[]): void; /** Synonymous with log0 */ log(...args: any[]): void; /** Outputs log at the named level granularity */ info9(...args: any[]): void; /** Outputs log at the named level granularity */ info8(...args: any[]): void; /** Outputs log at the named level granularity */ info7(...args: any[]): void; /** Outputs log at the named level granularity */ info6(...args: any[]): void; /** Outputs log at the named level granularity */ info5(...args: any[]): void; /** Outputs log at the named level granularity */ info4(...args: any[]): void; /** Outputs log at the named level granularity */ info3(...args: any[]): void; /** Outputs log at the named level granularity */ info2(...args: any[]): void; /** Outputs log at the named level granularity */ info1(...args: any[]): void; /** Outputs log at the named level granularity */ info0(...args: any[]): void; /** Synonymous with info0 */ info(...args: any[]): void; /** Outputs log at the named level granularity */ warn9(...args: any[]): void; /** Outputs log at the named level granularity */ warn8(...args: any[]): void; /** Outputs log at the named level granularity */ warn7(...args: any[]): void; /** Outputs log at the named level granularity */ warn6(...args: any[]): void; /** Outputs log at the named level granularity */ warn5(...args: any[]): void; /** Outputs log at the named level granularity */ warn4(...args: any[]): void; /** Outputs log at the named level granularity */ warn3(...args: any[]): void; /** Outputs log at the named level granularity */ warn2(...args: any[]): void; /** Outputs log at the named level granularity */ warn1(...args: any[]): void; /** Outputs log at the named level granularity */ warn0(...args: any[]): void; /** Synonymous with warn0 */ warn(...args: any[]): void; /** Used to output a log related to an error. */ error(...args: any[]): void; /** Used to output a log related to an exception.*/ exception(...args: any[]): void; /** Used to output a log related to non-recoverable crash.*/ fatal(...args: any[]): void; /** alias for fatal */ crash(...args: any[]): void; /** alias for trace */ Trace(...args: any[]): void; /** alias for debug */ Debug(...args: any[]): void; /** alias for log */ Log(...args: any[]): void; /** alias for info */ Info(...args: any[]): void; /** alias for warb */ Warn(...args: any[]): void; /** alias for error */ Error(...args: any[]): void; /** alias for fatal */ Critical(...args: any[]): void; /** alias for exception */ Exception(...args: any[]): void; /** * Declares the start of a contextual group of related log statements. * In the ConsoleWriter, Log statements following a group declaration appear slightly indented so as to form * a visually grouped collection. The group block is preceded by a label tag announcing the name of the group. * * Other Writer implementations may handle `group` blocks in different ways. Interactive log clients may support * collapsible sections. * * Groups are concluded with `groupEnd` statments. * * Groups initiated when another group is active appear nested within the former group. * * @param name */ group(name: string): void; /** * Marks the end of the current group. */ groupEnd(): void; } export {};