package com.livingworld.debug;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Central logging wrapper for the Living World mod.
 * <p>
 * All core systems should log through this class to ensure consistent
 * formatting and category grouping. Debug logs respect a future debug
 * configuration flag (TODO: wire config later).
 */
public final class LivingWorldLogger {

    private static Logger logger = LoggerFactory.getLogger("LivingWorld");

    // Prevent instantiation
    private LivingWorldLogger() {
    }

    /** Set the underlying SLF4J logger. */
    public static void setLogger(Logger newLogger) {
        if (newLogger == null) {
            throw new IllegalArgumentException("Logger must not be null");
        }
        logger = newLogger;
    }

    // ── Basic logging methods ───────────────────────────────

    public static void info(String message) {
        logger.info(message);
    }

    public static void warn(String message) {
        logger.warn(message);
    }

    public static void error(String message) {
        logger.error(message);
    }

    public static void error(String message, Throwable throwable) {
        logger.error(message, throwable);
    }

    public static void debug(String message) {
        // TODO: Respect debug config flag when ConfigService is available.
        logger.debug(message);
    }

    // ── Category-aware logging methods ──────────────────────

    public static void info(DiagnosticCategory category, String message) {
        logger.info("[{}] {}", category.displayName(), message);
    }

    public static void warn(DiagnosticCategory category, String message) {
        logger.warn("[{}] {}", category.displayName(), message);
    }

    public static void error(DiagnosticCategory category, String message) {
        logger.error("[{}] {}", category.displayName(), message);
    }

    public static void error(DiagnosticCategory category, String message, Throwable throwable) {
        logger.error("[{}] {}", category.displayName(), message, throwable);
    }

    public static void debug(DiagnosticCategory category, String message) {
        // TODO: Respect debug config flag when ConfigService is available.
        logger.debug("[{}] {}", category.displayName(), message);
    }
}
