package com.azerion.bluestack.react.utils;

import com.azerion.bluestack.react.BluestackManager;
import android.util.Log;

/**
 * Utility class for handling logging in the BlueStack SDK.
 * This class provides different log levels and respects the debug mode setting.
 */
public class BlueStackLogger {
    private static final String TAG = "BlueStackLogger";

    /**
     * Log levels for different types of messages
     */
    public enum LogLevel {
        DEBUG("BlueStack Bridge DEBUG"),
        INFO("BlueStack Bridge INFO"),
        WARNING("BlueStack Bridge WARNING"),
        ERROR("BlueStack Bridge ERROR");

        private final String value;
        LogLevel(String value) {
            this.value = value;
        }
        public String getValue() {
            return value;
        }
    }

    /**
     * Logs a debug message. Only prints if debug mode is enabled.
     * @param tag The tag to identify the source of the log
     * @param message The message to log
     */
    public static void debug(String tag, String message) {
        if (BluestackManager.getInstance().isDebugMode()) {
            Log.d(TAG, String.format("[%s] [%s] %s", LogLevel.DEBUG.getValue(), tag, message));
        }
    }

    /**
     * Logs an info message. Always prints regardless of debug mode.
     * @param tag The tag to identify the source of the log
     * @param message The message to log
     */
    public static void info(String tag, String message) {
        Log.i(TAG, String.format("[%s] [%s] %s", LogLevel.INFO.getValue(), tag, message));
    }

    /**
     * Logs a warning message. Always prints regardless of debug mode.
     * @param tag The tag to identify the source of the log
     * @param message The message to log
     */
    public static void warning(String tag, String message) {
        Log.w(TAG, String.format("[%s] [%s] %s", LogLevel.WARNING.getValue(), tag, message));
    }

    /**
     * Logs an error message. Always prints regardless of debug mode.
     * @param tag The tag to identify the source of the log
     * @param message The message to log
     */
    public static void error(String tag, String message) {
        Log.e(TAG, String.format("===[%s]===", LogLevel.ERROR.getValue()));
        Log.e(TAG, String.format("[%s] %s", tag, message));
        Log.e(TAG, "===========================");
    }

    /**
     * Logs an error message with throwable. Always prints regardless of debug mode.
     * @param tag The tag to identify the source of the log
     * @param message The message to log
     * @param throwable The throwable to log
     */
    public static void error(String tag, String message, Throwable throwable) {
        Log.e(TAG, String.format("===[%s]===", LogLevel.ERROR.getValue()));
        Log.e(TAG, String.format("[%s] %s", tag, message));
        Log.e(TAG, "===========================", throwable);
    }
} 