Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
chore: drop unnecessary Logger
Lars Wirzenius committed 1 year ago
commit ee177c8f202d52886e5d020ff837320eaa6d82ca
parent a506c6ebd37b9adf96b303ca5302d64e2e6bc07e
2 files changed +3 -61
modified src/bin/cibtool.rs
@@ -43,7 +43,7 @@ use radicle_ci_broker::{
mod cibtoolcmd;

fn main() {
-
    let _logger = logger::open(logger::LogLevel::Info);
+
    logger::open(logger::LogLevel::Info);
    if let Err(e) = fallible_main() {
        eprintln!("ERROR: {}", e);
        let mut e = e.source();
modified src/logger.rs
@@ -1,19 +1,11 @@
//! A logger abstraction for the CI broker.

-
#[cfg(test)]
-
use std::sync::Once;
-
use std::{
-
    path::Path,
-
    process::ExitStatus,
-
    sync::{Arc, Mutex},
-
    time::Duration,
-
};
+
use std::{path::Path, process::ExitStatus, time::Duration};

use clap::ValueEnum;
use radicle::{git::raw::Oid, identity::RepoId, node::Event};
use tracing::{debug, error, info, trace, warn, Level};
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
-
//use valuable::Valuable;

use crate::{
    ci_event::CiEvent,
@@ -89,21 +81,8 @@ impl From<LogLevel> for tracing::Level {
    }
}

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

-
impl Logger {
-
    pub fn set_minimum_level(&self, level: LogLevel) {
-
        *self
-
            .minimum_log_level
-
            .lock()
-
            .expect("set minimum log level") = level.into();
-
    }
-
}
-

#[allow(clippy::unwrap_used)]
-
pub fn open(level: LogLevel) -> Logger {
+
pub fn open(level: LogLevel) {
    #[cfg(test)]
    let writer = fmt::TestWriter::new();

@@ -118,43 +97,6 @@ pub fn open(level: LogLevel) -> Logger {
        .with(filter_layer)
        .with(fmt_layer)
        .init();
-

-
    // Set the default log level. Trace is good for tests.
-
    let level = Arc::new(Mutex::new(LogLevel::Trace.into()));
-

-
    Logger {
-
        minimum_log_level: level,
-
    }
-
}
-

-
// Set up structured logging for tests.
-
//
-
// We have to keep the GlobalLoggerGuard we get when we initialize
-
// `slog-scope` alive as long as we may need to do any logging. We can
-
// only create that once per process. For tests, we do that here.
-
//
-
// We can't do the same thing for non-test processes, as that would
-
// interfere with use of `radicle-ci-broker` as a library. Libraries
-
// should not interfere with global state, unless they're specifically
-
// intended to do that.
-
//
-
// This is for tests only: otherwise the default global logger is
-
// used, and that's OK for a long-running process.
-

-
// We use this to make sure we initialize the logger only once.
-
#[cfg(test)]
-
static INIT: Once = Once::new();
-

-
// This is the actual logger for tests.
-
#[cfg(test)]
-
static mut LOGGER: Option<Logger> = None;
-

-
#[cfg(test)]
-
#[ctor::ctor]
-
fn open_for_tests() {
-
    INIT.call_once(|| unsafe {
-
        LOGGER = Some(open(LogLevel::Trace));
-
    });
}

pub fn start_cib() {