WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Module logger

    Sovereign node logging system for WayrApp platform.

    This module provides a centralized, environment-aware logging solution built on Winston. It automatically adapts to serverless environments (Vercel, AWS Lambda, Netlify) by disabling file-based logging while maintaining console output. In traditional server environments, it provides both console and file-based logging with automatic log directory creation. The logger supports multiple log levels (error, warn, info, http, debug) with colorized console output and structured JSON file logging.

    Exequiel Trujillo

    1.0.0

    // Basic logging usage
    import { logger } from '@/shared/utils/logger';

    logger.info('User authentication successful', { userId: '123', method: 'JWT' });
    logger.warn('Rate limit approaching', { currentRequests: 95, limit: 100 });
    logger.error('Database connection failed', { error: error.message, retryCount: 3 });
    logger.debug('Cache hit', { key: 'user:123', ttl: 300 });
    // Environment-specific behavior
    // In serverless environments (Vercel, Lambda, Netlify):
    // - Only console logging is active
    // - No file system operations
    // - Structured JSON format for log aggregation

    // In traditional server environments:
    // - Console + file logging active
    // - Automatic logs/ directory creation
    // - Separate error.log and combined.log files
    // Configuration via environment variables
    // LOG_LEVEL=debug (enables all log levels)
    // LOG_LEVEL=info (default, enables info, warn, error)
    // LOG_LEVEL=error (only error logs)

    logger.debug('This appears only when LOG_LEVEL=debug');
    logger.info('This appears when LOG_LEVEL=info or debug');
    logger.error('This always appears unless LOG_LEVEL is disabled');