Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
chore: drop unused LogWriter
Lars Wirzenius committed 1 year ago
commit a506c6ebd37b9adf96b303ca5302d64e2e6bc07e
parent 9727a392aa15c1fdeb481dc4ec8809fc7d1417be
1 file changed +0 -40
modified src/logger.rs
@@ -3,7 +3,6 @@
#[cfg(test)]
use std::sync::Once;
use std::{
-
    io::Write,
    path::Path,
    process::ExitStatus,
    sync::{Arc, Mutex},
@@ -90,45 +89,6 @@ impl From<LogLevel> for tracing::Level {
    }
}

-
// A custom type for log output. We need this to hide log messages
-
// from output in successful tests. Cargo will hide standard output
-
// and error by default, which is what we want, but it seems this only
-
// applies to output via the `print!` family of macros. If we open a
-
// new handle for stdout or stderr, output via that handle is not
-
// captured by Cargo.
-
//
-
// Instead, we have our own log writer type that writes to stderr in
-
// production mode, and uses `print!` in tests.
-
#[derive(Default)]
-
struct LogWriter {}
-

-
#[cfg(test)]
-
impl Write for LogWriter {
-
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
-
        let s = String::from_utf8_lossy(buf);
-
        print!("{s}");
-
        Ok(buf.len())
-
    }
-

-
    fn flush(&mut self) -> std::io::Result<()> {
-
        Ok(())
-
    }
-
}
-

-
#[cfg(not(test))]
-
impl Write for LogWriter {
-
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
-
        let mut stderr = std::io::stderr();
-
        stderr.write_all(buf)?;
-
        stderr.flush()?;
-
        Ok(buf.len())
-
    }
-

-
    fn flush(&mut self) -> std::io::Result<()> {
-
        Ok(())
-
    }
-
}
-

pub struct Logger {
    minimum_log_level: Arc<Mutex<tracing::Level>>,
}