UNPKG

@wgtechlabs/log-engine

Version:

A lightweight, security-first logging utility with automatic data redaction for Node.js applications - the first logging library with built-in PII protection.

26 lines 1.21 kB
/** * Data formatting utilities for log output * Handles serialization and formatting of data objects in log messages */ import { LogData } from '../types'; /** * Converts input data to a readable string suitable for log output. * * Returns 'null' for `null`, an empty string for `undefined`, the value itself for strings, and string representations for numbers and booleans. For other types, attempts JSON serialization; if serialization fails, returns '[Object]'. * * @param data - The value to format for logging * @returns The formatted string representation of the input data */ export declare function formatData(data: LogData): string; /** * Applies color styling to a formatted data string using the provided color codes. * * @param dataString - The string to be styled; if falsy, an empty string is returned. * @param colors - An object containing `data` (the color code prefix) and `reset` (the color code suffix). * @returns The styled data string with color codes applied, or an empty string if `dataString` is falsy. */ export declare function styleData(dataString: string, colors: { data: string; reset: string; }): string; //# sourceMappingURL=data-formatter.d.ts.map