use boa_engine::{Context, JsResult, Trace};
use boa_gc::Finalize;
use boa_runtime::{ConsoleState, Logger};

#[derive(Trace, Finalize, Debug)]
pub(crate) struct StderrLogger;

impl Logger for StderrLogger {
    fn log(&self, msg: String, _state: &ConsoleState, _context: &mut Context) -> JsResult<()> {
        eprintln!("[LOG] {}", msg);
        Ok(())
    }

    fn info(&self, msg: String, _state: &ConsoleState, _context: &mut Context) -> JsResult<()> {
        eprintln!("[INFO] {}", msg);
        Ok(())
    }

    fn warn(&self, msg: String, _state: &ConsoleState, _context: &mut Context) -> JsResult<()> {
        eprintln!("[WARN] {}", msg);
        Ok(())
    }

    fn error(&self, msg: String, _state: &ConsoleState, _context: &mut Context) -> JsResult<()> {
        eprintln!("[ERROR] {}", msg);
        Ok(())
    }
}
