import { $instances } from '@-xun/debug'; import type { DebuggerExtension, ExtendedDebugger, InternalDebugger, UnextendableInternalDebugger, With$instances } from '@-xun/debug'; export type { With$instances }; export { $instances }; /** * Decorate a function `T` with an initial potentially-optional `tags` * parameter. */ export type WithExtendedParameters any, Optional = true> = Optional extends true ? [tags?: string[], ...Parameters] : [tags: string[], ...Parameters]; /** * Decorate a function-object `T` with an initial potentially-optional `tags` * parameter without excluding any of its non-function own object properties. */ export type WithTagSupport any, Optional = true> = ((...args: WithExtendedParameters) => ReturnType | undefined) & { [P in keyof T]: T[P] }; /** * An `ExtendedDebugger` function-object decorated with support for an initial * `tags` parameter. */ export type ExtendedLoggerParameters = WithExtendedParameters; /** * These color codes correspond to a reddish color on the console. * https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124?permalink_comment_id=4481079#gistcomment-4481079 */ export declare const ansiRedColorCodes: number[]; /** * These color codes correspond to a yellowish color on the console. * https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124?permalink_comment_id=4481079#gistcomment-4481079 */ export declare const ansiYellowColorCodes: number[]; /** * These color codes are tough to see on my personal terminals, or they're red (which are only used for errors) or yellow (only used for warnings). */ export declare const ansiBannedColorCodes: number[]; /** * Keeps track of our various "logger" (i.e. debug) instances and their * associated metadata. Also keeps track of those tags for which we disable * output. */ export declare const metadata: { logger: (ExtendedLogger | UnextendableInternalLogger)[]; debugger: (ExtendedDebugger | UnextendableInternalDebugger)[]; denylist: Set; }; /** * A function that resets the internal logger cache. Essentially, calling this * function causes rejoinder to forget any disabled tags or loggers created * prior. */ export declare function resetInternalState(): void; /** * Transforms an {@link ExtendedDebugger} into an {@link ExtendedLogger}. */ export declare function makeExtendedLogger(extendedDebugger: ExtendedDebugger, type: Exclude, /** * This function will be called with various arguments of unknown type when * default (e.g. stdout) output should be sent to the user, such as when * `::newline(...)` is called. */ underlyingDefaultLogFn: NonNullable, /** * This function will be called with various arguments of unknown type when * alternate (e.g. stderr) output should be sent to the user, such as when * `::newline(..., 'alternate')` and `::error(...)`, `::warn(...)`, * `::message(...)`, etc are called. */ underlyingAlternateLogFn?: NonNullable): ExtendedLogger; /** * Allows logging to be disabled via tags at the fine-grain message level. Set * `trapdoorArgLength` to the number of params necessary to trigger denylisting. */ export declare function decorateWithTagSupport any>(fn: T, trapdoorArgsMinLength: number): WithTagSupport; /** * Make rejoinder's internals aware of a new logger instance and its * pre-extended sub-instances. * * **This function MUST be invoked, and ONLY AFTER `::log` and * {@link $instances} have been configured on `logger`!** This allows all of * rejoinder's global enable/disable functions to work. */ export declare function withMetadataTracking(type: LoggerType.GenericOutput, logger: ExtendedLogger): ExtendedLogger; export declare function withMetadataTracking(type: LoggerType.DebugOnly, logger: ExtendedDebugger): ExtendedDebugger; export declare function withMetadataTracking(type: Exclude, logger: ExtendedDebugger | ExtendedLogger): ExtendedDebugger | ExtendedLogger; /** * Make rejoinder's internals forget a logger instance and its pre-extended * sub-instances. * * **This function MUST be invoked for descendant loggers, and ONLY AFTER * creating a new generic/debug `logger` that will be extended with additional * functionality but BEFORE passing that finalized `logger` to * {@link withMetadataTracking}!** This prevents memory leaks. */ export declare function withoutMetadataTracking(type: LoggerType.GenericOutput, logger: ExtendedLogger): ExtendedLogger; export declare function withoutMetadataTracking(type: LoggerType.DebugOnly, logger: ExtendedDebugger): ExtendedDebugger; export declare function withoutMetadataTracking(type: Exclude, logger: ExtendedDebugger | ExtendedLogger): ExtendedDebugger | ExtendedLogger; /** * Recursively patches {@link ExtendedDebugger.extend} so that all debugger * instances are properly tracked. */ export declare function withPatchedExtend(instance: ExtendedDebugger): ExtendedDebugger; /** * Returns all keys in an object's {@link $instances} property with proper * types. */ export declare function get$instancesKeys, typeof $instances>>(logger: T): (keyof (typeof logger)[typeof $instances])[]; /** * An enum representing the types of loggers classified by output target. */ export declare enum LoggerType { All = "all", GenericOutput = "logger", DebugOnly = "debugger", } /** * An instance of {@link UnextendableInternalDebugger} that that belongs to an * {@link ExtendedLogger}. */ export interface UnextendableInternalLogger extends UnextendableInternalDebugger { /** * Send an optionally-formatted message to output. */ (...args: Parameters): ReturnType; /** * Send a tagged optionally-formatted message to output. */ (...args: ExtendedLoggerParameters): ReturnType; } /** * A wrapper around {@link ExtendedDebugger } representing the extension from * mere "debug" logger to general purpose "logger". */ export interface ExtendedLogger extends _ExtendedLogger { /** * Send an optionally-formatted message to output. */ (...args: Parameters): ReturnType; /** * Send a tagged optionally-formatted message to output. */ (...args: ExtendedLoggerParameters): ReturnType; /** * Send a blank newline to output. * * `outputMethod` determines if the newline will be output via the default * output method or the alternate output method. This parameter only has an * effect when using certain logger backends and typically corresponds to * stdout (`"default"`) and stderr (`"alternate"`). */ newline(...args: [...WithExtendedParameters, outputMethod?: 'default' | 'alternate']): ReturnType; /** * Send a blank newline to output. * * `outputMethod` determines if the newline will be output via the default * output method or the alternate output method. This parameter only has an * effect when using certain logger backends and typically corresponds to * stdout (`"default"`) and stderr (`"alternate"`). */ newline(...args: [outputMethod?: 'default' | 'alternate']): ReturnType; /** * Creates a new instance by appending `namespace` to the current instance's * namespace. The new instance will also inherit the current instance's `log` * function, if one exists, though **the two functions will not be strictly * equal.** */ extend: (...args: Parameters) => ExtendedLogger; } type _ExtendedLogger = Omit & DebuggerExtension;