import { LevelInfo, LevelsMap } from 'rfc-log-levels'; import { Offset, Location } from 'get-current-line'; import { Transform } from './transform.js'; /** The log entry that Caterpillar creates and forwards to its transforms */ export interface LogEntry extends LevelInfo, Location { /** the iso string of when the log occured */ date: string; /** all the arguments that were after the log level */ args: any[]; } /** Configuration for the Caterpillar Logger */ export interface LoggerOptions { /** Use to override the default value of {@link Logger.lineOffset} */ lineOffset?: Offset; /** Use to override the default value of {@link Logger.levels} */ levels?: LevelsMap; /** Use to override the default value of {@link Logger.defaultLevelInfo} */ defaultLevel?: number | string; /** Use to override the default value of {@link Logger.lineLevel} */ lineLevel?: number; } /** * Logger. * This is what we write to. * @example Creation * ``` javascript * // Via class * import { Logger } from 'caterpillar' * const logger = new Logger() * ``` */ export declare class Logger extends Transform { /** * The configuration to use for the line offset. * This defaults to any file path that includes `logger`, and any method that includes the word `log`. */ lineOffset: Offset; /** * The mapping of log level names to log level numbers. * Defaults to the RFC Log Level configuration. */ levels: LevelsMap; /** * The log level information to use when the log level was unable to be determined. * Defaults to the info log level. */ defaultLevelInfo: LevelInfo; /** Set the default level info via a level number or name. */ set defaultLevel(value: number | string); /** * Only fetch line information for entries that have a log level equal to, or below this number. * You should only specify this if you need it, as fFetching line information for thousands of log entries, which is typical in large applications, will slow your application down dramatically. * If not specified, defaults to `-Infinity` which effect is to ignore gathering line information for all log levels. */ lineLevel: number; /** Create our instance and apply our configuraiton options. */ constructor(opts?: LoggerOptions); /** Alias for {@link getLogLevel} using the configured logger levels as reference. */ getLogLevel(value: number | string): LevelInfo | null; /** Takes an arguments array and tranforms it into a log entry. */ format(args: any): LogEntry; /** * Log the arguments into the logger stream as formatted data with debugging information. * Such that our transformers can deal with it intelligently. * * @example Inputs * ``` javascript * logger.log('note', 'this is working swell') * ``` * ``` javascript * logger.log('this', 'worked', 'swell') * ``` * * @example Results * ``` json * { * "args": ["this is working swell"], * "date": "2013-04-25T10:18:25.722Z", * "levelNumber": 5, * "levelName": "notice", * "line": "59", * "method": "Object.", * "file": "/Users/balupton/some-project/calling-file.js" * } * ``` * ``` json * { * "args": ["this", "worked", "well"], * "date": "2013-04-25T10:18:26.539Z", * "levelNumber": 6, * "levelName": "info", * "line": "60", * "method": "Object.", * "file": "/Users/balupton/some-project/calling-file.js" * } * ``` */ log(...args: any): void; /** Alias for log which prefixes the error log level */ error(...args: any): void; /** Alias for log which prefixes the warn log level */ warn(...args: any): void; /** Alias for log which prefixes the info log level */ info(...args: any): void; /** Alias for log which prefixes the debug log level */ debug(...args: any): void; } export default Logger; //# sourceMappingURL=logger.d.ts.map