import { TerminalColors } from './lib/terminal'; import { LogLevel } from './logLevel'; declare global { const __webpack_require__: any | undefined; namespace NodeJS { interface Global { __webpack_require__: any | undefined; } } } export interface ILogOptions { /** The log level */ level?: LogLevel; /** Whether to log using colors. Default true */ useColors?: boolean; /** Whether to log as JSON. Default false */ asJSON?: boolean; /** A custom adapter that will be called with log messages. If not set, console.log is used */ customAdapter?: LogAdapter; /** Whether to show file path / line numbers for all logs instead of just debug and trace. Enabling this will incur a slight performance penalty. */ showLineNumbersForAll?: boolean; /** * If this is a module, set the namespace so logs can be selectively turned on. * * For example, if the module is named @kengoldfarb/foo * * You can turn on debugging by setting the environment variable: * DEBUG=@kengoldfarb/foo * or with a wildcard * DEBUG=@kengoldfarb/* * * You can also specify the level: * DEBUG=@kengoldfarb/foo~trace,@kengoldfarb/bar~crit * * By default, when a namespace is set, the level is set to "warn" * * */ namespace?: string; } export interface ICaller { stack?: string; fullFilePath?: string; relativeFilePath?: string; } /** Corresponds to the signature of console.log */ export type LogAdapter = (message?: any, ...optionalParams: any[]) => void; export interface ILevel { i: number; hex: string; bgHex: string | null; terminalColor: TerminalColors; } export declare class Log { /** The tab size of an object when stringified */ private objectSpaceWidth; private useColors; private asJSON; private showLineNumbersForAll; private level; private customAdapter?; private consoleAdapter; private namespace?; private stackUtils; private levels; constructor(options?: ILogOptions); /** Trace level logs the go beyond just normal debug messages. A silly log level. */ trace(...args: any[]): void; /** Debug messages used during development. */ debug(...args: any[]): void; /** Informational messages */ info(...args: any[]): void; /** Something bad might have happened and it should be invesigated, but we can continue. */ warn(...args: any[]): void; /** Something bad happened, but we can continue or recover. */ error(...args: any[]): void; /** Something critical happend that likely had unintended or fatal consequences */ crit(...args: any[]): void; /** Something happened and we must immediately stop */ fatal(...args: any[]): void; /** Really important information that is ALWAYS logged */ superInfo(...args: any[]): void; /** Start a timer. Pass the response to timerEnd() to get the elapsed time */ timerStart(): [number, number]; /** Returns the elapsed time in milliseconds */ timerEnd(timeStart: [number, number]): number; /** Set logger options */ setOptions(options?: ILogOptions): void; private getCaller; /** Set the log level */ private setLevel; private getLevelFromString; private handleLog; private anyToString; private colorize; private writeLog; private getDatetimeString; private getAdapter; private setConsoleAdapter; private replaceErrors; /** Logs a debug message about @kengoldfarb/log itself */ private debugLog; private setDefaultOptions; private getDebugString; private getDefaultLevelForNamespace; private parseNamespace; private hrtime; } export default Log;