legal-markdown-js
Version:
Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version
99 lines • 3.6 kB
TypeScript
/**
* @fileoverview Lightweight Logging Utility for Legal Markdown Processing
*
* This module provides a simple, efficient logging utility for the Legal Markdown
* processing system. It offers structured logging with different levels and
* optional data context support.
*
* Features:
* - Multiple log levels (debug, info, warn, error)
* - Debug mode controlled by environment variable
* - Structured logging with contextual data
* - stderr output via process.stderr.write (debug/info) and console.warn/error (warn/error)
* - Optional data parameter for detailed logging
* - Lightweight with no external dependencies
*
* @example
* ```typescript
* import { logger } from './logger.js';
*
* // Basic logging
* logger.info('Processing legal document');
* logger.warn('Missing field detected');
* logger.error('Failed to parse YAML');
*
* // Logging with context data
* logger.debug('Field processed', { fieldName: 'client.name', value: 'Acme Corp' });
* logger.info('Document exported', { format: 'pdf', size: '2.3MB' });
* ```
*/
export declare const logger: {
/**
* Enable or disable debug logging
* @param {boolean} enabled - Whether to enable debug logging
*/
setDebugEnabled: (enabled: boolean) => void;
/**
* Set the logging level
* @param {string} level - The log level ('debug', 'info', 'warn', 'error', 'none')
*/
setLogLevel: (level: "debug" | "info" | "warn" | "error" | "none") => void;
/**
* Log debug messages (only shown when DEBUG environment variable is set or debug is enabled)
*
* debug
* @param {string} message - The debug message to log
* @param {any} [data] - Optional contextual data to include with the log
* @returns {void}
* @example
* ```typescript
* // Enable debug mode: DEBUG=true node app.js or logger.setDebugEnabled(true)
* logger.debug('Processing field', { name: 'client.name', type: 'string' });
* logger.debug('Import resolved', { path: './shared/header.md' });
* ```
*/
debug: (message: string, data?: unknown) => void;
/**
* Log informational messages
*
* info
* @param {string} message - The informational message to log
* @param {any} [data] - Optional contextual data to include with the log
* @returns {void}
* @example
* ```typescript
* logger.info('Document processing completed');
* logger.info('Export successful', { format: 'html', path: './output.html' });
* ```
*/
info: (message: string, data?: unknown) => void;
/**
* Log warning messages
*
* warn
* @param {string} message - The warning message to log
* @param {any} [data] - Optional contextual data to include with the log
* @returns {void}
* @example
* ```typescript
* logger.warn('Missing optional field', { field: 'client.phone' });
* logger.warn('Import file not found', { path: './missing.md' });
* ```
*/
warn: (message: string, data?: unknown) => void;
/**
* Log error messages
*
* error
* @param {string} message - The error message to log
* @param {any} [data] - Optional contextual data to include with the log
* @returns {void}
* @example
* ```typescript
* logger.error('Failed to parse YAML frontmatter', { error: 'Invalid syntax' });
* logger.error('Document processing failed', { file: 'contract.md', reason: 'Missing imports' });
* ```
*/
error: (message: string, data?: unknown) => void;
};
//# sourceMappingURL=logger.d.ts.map