use codemap::SpanLoc;
use std::fmt::Debug;
pub trait Logger: Debug {
fn debug(&self, location: SpanLoc, message: &str);
fn warn(&self, location: SpanLoc, message: &str);
}
#[derive(Debug)]
pub struct StdLogger;
impl Logger for StdLogger {
#[inline]
fn debug(&self, location: SpanLoc, message: &str) {
eprintln!(
"{}:{} DEBUG: {}",
location.file.name(),
location.begin.line + 1,
message
);
}
#[inline]
fn warn(&self, location: SpanLoc, message: &str) {
eprintln!(
"Warning: {}\n ./{}:{}:{}",
message,
location.file.name(),
location.begin.line + 1,
location.begin.column + 1
);
}
}
#[derive(Debug)]
pub struct NullLogger;
impl Logger for NullLogger {
#[inline]
fn debug(&self, _location: SpanLoc, _message: &str) {}
#[inline]
fn warn(&self, _location: SpanLoc, _message: &str) {}
}