import type { Some } from '@xh/hoist/core'; import { type NameSource } from './LangUtils'; /** * Utility functions providing managed, structured logging to Hoist apps. * * Essentially a wrapper around the browser console supporting logging levels, timing, and * miscellaneous Hoist display conventions. * * Objects extending `HoistBase` need not import these functions directly, as they are available * via delegates on `HoistBase`. * * Hoist sets its minimum severity level to 'info' by default. This prevents performance or * memory impacts that might result from verbose debug logging. This can be adjusted by calling * XH.logLevel from the console. */ /** Severity Level for log statement */ export type LogLevel = 'error' | 'warn' | 'info' | 'debug'; /** @deprecated Use {@link NameSource} from LangUtils. */ export type LogSource = NameSource; export interface APIWarnOptions { /** * If provided and undefined, this method will be a no-op. * Useful for testing if a parameter has been provided in caller. */ test?: any; /** Version when this API will no longer be supported or this warning should be removed. */ v?: string; /** An additional message. Can contain suggestions for alternatives. */ msg?: string; /** Source of message for labelling log message. */ source?: NameSource; } /** * Current minimum severity for Hoist log utils (default 'info'). * Messages logged via managed Hoist log utils with lower severity will be ignored. * * @internal - use public `XH.logLevel`. */ export declare function getLogLevel(): LogLevel; /** * Set the minimum severity for Hoist log utils until the page is refreshed. Optionally persist * this adjustment to localStorage for up to 24 hours. * * @internal - use public `XH.setLogLevel()`. */ export declare function setLogLevel(level: LogLevel, persistMins?: number): void; /** * Time and log execution of a function to `console.info()`. * * This method will log the provided message(s) with timing information in a single message *after* * the tracked function returns. * * If the function passed to this util returns a Promise, it will wait until the Promise resolves * or completes to finish its logging. The actual object returned by the tracked function will * always be returned directly to the caller. * * @param msgs - message(s) to output after the execution "completes" * @param fn - function to execute * @param source - class, function or string to label the source of the message */ export declare function withInfo(msgs: Some, fn: () => T, source?: NameSource): T; /** * Time and log execution of a function to `console.debug()`. * @see withInfo */ export declare function withDebug(msgs: Some, fn: () => T, source?: NameSource): T; /** * Write to `console.log()` with standardized formatting and source info. * @param msgs - message(s) to output * @param source - class, function or string to label the source of the message */ export declare function logInfo(msgs: Some, source?: NameSource): unknown; /** * Write to `console.debug()` with standardized formatting and source info. * @param msgs - message(s) to output * @param source - class, function or string to label the source of the message */ export declare function logDebug(msgs: Some, source?: NameSource): unknown; /** * Write to `console.error()` with standardized formatting and source info. * @param msgs - message(s) to output * @param source - class, function or string to label the source of the message */ export declare function logError(msgs: Some, source?: NameSource): unknown; /** * Write to `console.warn()` with standardized formatting and source info. * @param msgs - message(s) to output * @param source - class, function or string to label the source of the message */ export declare function logWarn(msgs: Some, source?: NameSource): unknown; /** * Log a warning to the console if a condition evaluates as truthy. */ export declare function warnIf(condition: any, message: any): void; /** * Log an error to the console if a condition evaluates as truthy. */ export declare function errorIf(condition: any, message: any): void; /** * Document and prevent usage of a removed parameter. */ export declare function apiRemoved(name: string, opts?: APIWarnOptions): void; export declare function apiDeprecated(name: string, opts?: APIWarnOptions): void;