/** * Logger Utility for OpenFin Workspace Monorepo * * Provides structured, contextual logging with consistent formatting * across all workspaces and modules. */ export interface LogData { [key: string]: any; } export interface Logger { debug: (method: string, message: string, data?: LogData | (() => LogData)) => void; info: (method: string, message: string, data?: LogData | (() => LogData)) => void; warn: (method: string, message: string, data?: LogData | (() => LogData)) => void; error: (method: string, message: string, data?: LogData | (() => LogData)) => void; } /** * Configuration for the logger */ export interface LoggerConfig { /** Include timestamp in logs (default: true) */ includeTimestamp?: boolean; /** Custom prefix for logs */ customPrefix?: string; /** * Stringify log data before passing to console (default: true). * When true, objects are serialized as JSON strings for safer logging. * When false, raw objects are passed to console, allowing expandable/inspectable * objects in browser dev tools. * * @example * To disable safe stringify for local development, you can: * 1. Set this option per-logger: createLogger('MyContext', { stringifyData: false }) * 2. Or call setGlobalStringifyEnabled(false) once at app startup */ stringifyData?: boolean; } /** * Enable or disable safe stringify globally for all loggers. * Useful for local development when you want expandable objects in browser dev tools. * * This overrides the build-time LOG_STRINGIFY setting at runtime. * Individual logger config (stringifyData option) takes precedence over this setting. * * @param enabled - Whether to stringify log data * * @example * ```typescript * // Override build-time setting at runtime: * import { setGlobalStringifyEnabled } from 'common/src/utils/logger'; * * // Disable stringify to get expandable objects in console * setGlobalStringifyEnabled(false); * ``` */ export declare const setGlobalStringifyEnabled: (enabled: boolean) => void; /** * Get the current global stringify setting. */ export declare const getGlobalStringifyEnabled: () => boolean; /** * Create a structured logger for a specific context * * @param context - The context identifier (workspace, module, or component name) * @param config - Optional configuration for the logger * @returns Enhanced logger instance * * @example * ```typescript * const logger = createLogger('browser.TabList'); * * logger.info('addTab', 'Adding new tab', { pageId: '123' }); * logger.error('addTab', 'Failed to add tab', { error: err.message }); * ``` */ export declare const createLogger: (context: string, config?: LoggerConfig) => Logger; /** * Create a logger with performance monitoring capabilities * Useful for tracking execution times and performance metrics */ export declare const createPerformanceLogger: (context: string, config?: LoggerConfig) => { /** * Start a performance timer */ startTimer: (timerId: string, method: string, message: string, data?: LogData) => void; /** * Clear a specific timer without logging */ clearTimer: (timerId: string) => void; /** * End a performance timer and log the duration */ endTimer: (timerId: string, method: string, message: string, data?: LogData) => void; debug: (method: string, message: string, data?: LogData | (() => LogData)) => void; info: (method: string, message: string, data?: LogData | (() => LogData)) => void; warn: (method: string, message: string, data?: LogData | (() => LogData)) => void; error: (method: string, message: string, data?: LogData | (() => LogData)) => void; }; export type EnhancedLogger = ReturnType; /** * Middleware function for wrapping async operations with logging */ export declare const withLogging: (logger: Logger, method: string, operation: (...args: T) => Promise | R) => (...args: T) => Promise; /** * Legacy logger instance for backwards compatibility. * Use `createLogger` for new code to get structured, contextual logging. * * @deprecated Use createLogger() instead for new code */ export declare const log: { /** * Calls console.debug with provided parameters and stringifies JS objects prior to logging. * Only logs when LOG_DEBUG is enabled. */ debug: (...args: unknown[]) => void; /** * Calls console.info with provided parameters and stringifies JS objects prior to logging */ info: (...args: unknown[]) => void; /** * Calls console.warn with provided parameters and stringifies JS objects prior to logging */ warn: (...args: unknown[]) => void; /** * Calls console.error with provided parameters and stringifies JS objects prior to logging */ error: (...args: unknown[]) => void; /** * Calls console.trace with provided parameters and stringifies JS objects prior to logging */ trace: (...args: unknown[]) => void; };