//! Logging (as in terms of console / serial output)
#![allow(deprecated)]
use {core::fmt::Write, spin::Mutex, uart_16550::SerialPort};

pub static SERIAL_CONSOLE: Mutex<SerialPort> = Mutex::new(unsafe { SerialPort::new(0x3F8) });

pub fn init() {
    SERIAL_CONSOLE.lock().init();
    // Lazy::force(&TERMINAL_LOGGER);
}

pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
    x86_64::instructions::interrupts::without_interrupts(|| {
        // TERMINAL_LOGGER.lock().write_fmt(args)?;
        SERIAL_CONSOLE.lock().write_fmt(args)
    })
}