UNPKG

@ozmap/logger

Version:
84 lines (83 loc) 2.68 kB
import { LogLevels } from './enum/LogLevels'; import { LoggerColorized } from './interface/LoggerColorized'; import { Outputs } from './enum/Outputs'; /** * Outputs the stringified version of the input data. * * @param data The data to stringify. * @returns The stringified data. */ export declare function stringify(data: unknown): string; /** * Creates a replacer function for JSON.stringify to handle circular references. * This version tracks parent objects (ancestors) to detect cycles. * When a circular reference is detected, it returns the string "[Circular]" for that property. * * @returns A replacer function that handles circular objects by returning "[Circular]". */ export declare function getCircularReplacer(): (this: unknown, key: string, value: unknown) => unknown; /** * Outputs the normalized version of the input data. * * @param data The data to normalize. * @returns The normalized data. */ export declare function normalize(data: unknown): unknown; /** * Factory function to create painter for log output coloring. * * @returns Readonly object with level tags as painter methods. */ export declare function colorized(): Readonly<LoggerColorized>; /** * Function for checking the data type without relying on * the generic typeof functionality. * * @param data The data being checked for its type. * @returns The internal tag that represents the data type. */ export declare function typeOf(data: unknown): string; /** * Function for checking if data is a key/value pair object. * * @param data The data being checked. * @returns Whether or not the data is an object. */ export declare function isJsonObject(data: unknown): boolean; /** * Function for checking if data is an array object. * * @param data The data being checked. * @returns Whether or not the data is an array. */ export declare function isJsonArray(data: unknown): boolean; /** * Retrieve the current log level name. * * @returns The level name. */ export declare function level(): keyof typeof LogLevels; /** * Check if the log outputs should be colorized. * * @returns Whether or not the output can be colorized. */ export declare function color(): boolean; /** * Check which output should be used for logging. * * @returns Output name to be used. */ export declare function output(): (typeof Outputs)[number]; /** * Return the current date and time closure. * * @returns The current datetime closure. */ export declare function datetime<T>(): () => T; /** * Parse the log server port and interface to bind to. * * @returns The port number and interface address. */ export declare function host(): [number, string];