/**
 * Centralized Logger Service
 * helps standardise logging across the application.
 */

const LOG_LEVELS = {
    INFO: 'info',
    WARN: 'warn',
    ERROR: 'error',
};

// Toggle this to false in production to suppress logs
const IS_DEV = import.meta.env.DEV;

const formatMessage = (level, message, context) => {
    const timestamp = new Date().toISOString();
    return {
        timestamp,
        level,
        message,
        context,
    };
};

export const logger = {
    info: (message, context = {}) => {
        if (IS_DEV) {
            console.log(`%c[INFO] ${message}`, 'color: #3b82f6; font-weight: bold;', context);
        }
    },

    warn: (message, context = {}) => {
        console.warn(`%c[WARN] ${message}`, 'color: #f59e0b; font-weight: bold;', context);
    },

    error: (message, error = null, context = {}) => {
        console.error(`%c[ERROR] ${message}`, 'color: #ef4444; font-weight: bold;', {
            error,
            ...context,
        });
        // In a real app, you might send this to Sentry/LogRocket here
    },
};
