Repository: rust-lang/rust
File: compiler/rustc_log/src/lib.rs (Rust)

Code before:
    let verbose_entry_exit = match cfg.verbose_entry_exit {
        Ok(v) => &v != "0",
        Err(_) => false,
    };

    let verbose_thread_ids = match cfg.verbose_thread_ids {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let lines = match cfg.lines {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let json = match cfg.json {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let output_target: BoxMakeWriter = match cfg.output_target {
        Ok(v) => match File::options().create(true).write(true).truncate(true).open(&v) {
            Ok(i) => BoxMakeWriter::new(Mutex::new(i)),
            Err(e) => {
                eprintln!("couldn't open {v} as a log target: {e:?}");
                BoxMakeWriter::new(io::stderr)
            }
        },
        Err(_) => BoxMakeWriter::new(io::stderr),
    };

    let layer = if json {
        let format = tracing_subscriber::fmt::format()
            .json()
            .with_span_list(true)
            .with_source_location(true);

        let fmt_layer = tracing_subscriber::fmt::layer()
            .json()
            .event_format(format)
            .with_writer(output_target)
            .with_target(true)
            .with_ansi(false)
            .with_thread_ids(verbose_thread_ids)
            .with_thread_names(verbose_thread_ids)
            .with_span_events(FmtSpan::ACTIVE);
        Layer::boxed(fmt_layer)
    } else {
        let mut layer = tracing_tree::HierarchicalLayer::default()
            .with_writer(output_target)
            .with_ansi(color_logs)

Review comment (suggestion):
not 100% familiar with that crate, but just wondering if that's fine to use `eprintln` here

Code after:

    let verbose_entry_exit = match cfg.verbose_entry_exit {
        Ok(v) => &v != "0",
        Err(_) => false,
    };

    let verbose_thread_ids = match cfg.verbose_thread_ids {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let lines = match cfg.lines {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let json = match cfg.json {
        Ok(v) => &v == "1",
        Err(_) => false,
    };

    let output_target: BoxMakeWriter = match cfg.output_target {
        Ok(v) => match File::options().create(true).write(true).truncate(true).open(&v) {
            Ok(i) => BoxMakeWriter::new(Mutex::new(i)),
            Err(e) => {
                eprintln!("couldn't open {v} as a log target: {e:?}");
                BoxMakeWriter::new(io::stderr)
            }
        },
        Err(_) => BoxMakeWriter::new(io::stderr),
    };

    let layer = if json {
        let format = tracing_subscriber::fmt::format()
            .json()
            .with_span_list(true)
            .with_source_location(true);

        let fmt_layer = tracing_subscriber::fmt::layer()
            .json()
            .event_format(format)
            .with_writer(output_target)
            .with_target(true)
            .with_ansi(false)
            .with_thread_ids(verbose_thread_ids)
            .with_thread_names(verbose_thread_ids)
            .with_span_events(FmtSpan::ACTIVE);
        Layer::boxed(fmt_layer)
    } else {
        let mut layer = tracing_tree::HierarchicalLayer::default()
            .with_writer(output_target)