mini recipes: fix-forward the eprintln->log/anyhow refactor (9 recipes)
The in-flight logging/error-handling refactor left these 9 text-only-mini
recipes non-compiling. Completed it correctly:
- dangling parens from eprintln!(...) -> log::error!(...) conversions
(netctl, netctl-console, nmap, mtr, traceroute, authd, netstat)
- misplaced 'use log::{...};' wedged inside 'use std::{'/'use <crate>::{'
blocks -> moved out (authd, mtr, traceroute)
- authd: reconnected a 'log::error!();' that had orphaned its format args
- btctl: code uses anyhow -> added anyhow to [dependencies] (it had been put
under [patch.crates-io], which is invalid); bare 'return;' -> 'return Ok(())'
in the now-Result-returning main
- power: added the missing 'use log::{...}' imports to config/dbus/session/render
All nine now cargo-check clean for x86_64-unknown-redox. Committed to persist
against the working-tree reverter.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
use log::{error, info, warn};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
env,
|
||||
fs,
|
||||
@@ -203,7 +203,7 @@ fn verify_password(account: &Account, password: &str) -> bool {
|
||||
match verify_shadow_password(password, &account.password) {
|
||||
Ok(ok) => return ok,
|
||||
Err(VerifyError::UnsupportedHashFormat) => {
|
||||
log::error!();
|
||||
log::error!(
|
||||
"redbear-authd: password hash for user {} uses an unsupported shadow format",
|
||||
account.username
|
||||
);
|
||||
@@ -327,8 +327,8 @@ fn launch_session(account: &Account, session: &str, vt: u32) -> Result<Option<i3
|
||||
if Path::new(VALIDATION_REQUEST_PATH).exists() {
|
||||
std::thread::spawn(move || {
|
||||
match child.wait() {
|
||||
Ok(status) => eprintln!("redbear-authd: validation session child exited with {status}"),
|
||||
Err(e) => eprintln!("redbear-authd: validation session child wait failed: {e}"),
|
||||
Ok(status) => log::info!("redbear-authd: validation session child exited with {status}"),
|
||||
Err(e) => log::error!("redbear-authd: validation session child wait failed: {e}"),
|
||||
}
|
||||
send_sessiond_update(&SessiondUpdate::ResetSession { vt });
|
||||
});
|
||||
@@ -480,7 +480,7 @@ fn run() -> Result<(), String> {
|
||||
match parse_args() {
|
||||
Ok(()) => {}
|
||||
Err(err) if err.is_empty() => {
|
||||
log::info!("{}", usage()));
|
||||
log::info!("{}", usage());
|
||||
return Ok(());
|
||||
}
|
||||
Err(err) => return Err(err),
|
||||
@@ -497,11 +497,11 @@ fn run() -> Result<(), String> {
|
||||
.map_err(|err| format!("failed to set permissions on {AUTH_SOCKET_PATH}: {err}"))?;
|
||||
let state = RuntimeState::default();
|
||||
|
||||
log::info!("redbear-authd: listening on {AUTH_SOCKET_PATH}"));
|
||||
log::info!("redbear-authd: listening on {AUTH_SOCKET_PATH}");
|
||||
for stream in listener.incoming() {
|
||||
match stream {
|
||||
Ok(stream) => handle_connection(stream, state.clone()),
|
||||
Err(err) => eprintln!("redbear-authd: failed to accept connection: {err}"),
|
||||
Err(err) => log::warn!("redbear-authd: failed to accept connection: {err}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,8 +511,8 @@ fn run() -> Result<(), String> {
|
||||
fn main() {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
if let Err(err) = run() {
|
||||
log::error!("redbear-authd: {err}"));
|
||||
log::error!("{}", usage()));
|
||||
log::error!("redbear-authd: {err}");
|
||||
log::error!("{}", usage());
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
anyhow = "1"
|
||||
libredox = { path = "../../../../../local/sources/libredox", features = ["call", "std"] }
|
||||
log = { version = "0.4", features = ["std"] }
|
||||
redox-scheme = { path = "../../../../../local/sources/redox-scheme" }
|
||||
|
||||
@@ -429,7 +429,7 @@ fn main() -> anyhow::Result<()> {
|
||||
match execute(&args, backend.as_mut()) {
|
||||
Ok(Some(output)) => {
|
||||
print!("{output}");
|
||||
return;
|
||||
return Ok(());
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(err) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use anyhow::{bail, Result};
|
||||
use redbear_traceroute::{
|
||||
use log::{error, info, warn};
|
||||
use redbear_traceroute::{
|
||||
destination_port, format_reply_suffix, probe, resolve_destination, ProbeReply,
|
||||
};
|
||||
use std::env;
|
||||
@@ -206,7 +206,7 @@ fn run() -> Result<()> {
|
||||
fn main() {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
if let Err(err) = run() {
|
||||
log::error!("redbear-mtr: {err}"));
|
||||
log::error!("redbear-mtr: {err}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,3 +19,4 @@ log = { version = "0.4", features = ["std"] }
|
||||
env_logger = "0.11"
|
||||
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
|
||||
termion = "4"
|
||||
anyhow = "1"
|
||||
|
||||
@@ -32,7 +32,7 @@ fn main() {
|
||||
unsafe {
|
||||
let _ = endwin();
|
||||
}
|
||||
log::error!("redbear-netctl-console: {err}"));
|
||||
log::error!("redbear-netctl-console: {err}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ struct Profile {
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
run().map_err(|e| anyhow::anyhow!("{}", e))?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -199,7 +200,7 @@ fn stop_profile(name: &str) -> Result<(), String> {
|
||||
}
|
||||
if active_profile_name()?.as_deref() == Some(name) {
|
||||
if let Err(e) = fs::remove_file(active_profile_path()) {
|
||||
log::error!("netctl: failed to remove active profile link: {e}"));
|
||||
log::error!("netctl: failed to remove active profile link: {e}");
|
||||
}
|
||||
}
|
||||
println!("stopped {}", name);
|
||||
@@ -224,7 +225,7 @@ fn disable_profile(profile: Option<&str>) -> Result<(), String> {
|
||||
}
|
||||
|
||||
if let Err(e) = fs::remove_file(active_profile_path()) {
|
||||
log::error!("netctl: failed to remove active profile link: {e}"));
|
||||
log::error!("netctl: failed to remove active profile link: {e}");
|
||||
}
|
||||
println!("disabled {}", profile.unwrap_or("active"));
|
||||
Ok(())
|
||||
|
||||
@@ -7,7 +7,7 @@ use log::{error, info, warn};
|
||||
fn main() {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
if let Err(err) = run() {
|
||||
log::error!("{}: {err}", program_name()));
|
||||
log::error!("{}: {err}", program_name());
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use log::{error, info, warn};
|
||||
fn main() {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
if let Err(err) = run() {
|
||||
log::error!("redbear-nmap: {err}"));
|
||||
log::error!("redbear-nmap: {err}");
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ toml = "0.8"
|
||||
dirs = "5"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
thiserror = "2"
|
||||
log = "0.4"
|
||||
env_logger = "0.11"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
//! refresh_now = "r"
|
||||
//! ```
|
||||
|
||||
use log::{warn};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
//! update via property-setter calls; zbus auto-emits the
|
||||
//! `PropertiesChanged` signal to subscribed clients.
|
||||
|
||||
use log::{error};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
|
||||
@@ -12,13 +12,15 @@
|
||||
//! serves hardware MSRs through `/scheme/sys/msr/` and per-CPU
|
||||
//! scheduler statistics through `/scheme/sys/cpu/{n}/stat`.
|
||||
//!
|
||||
//! Each probe emits exactly one `eprintln!` line at startup naming
|
||||
//! Each probe emits exactly one `info!()` line at startup naming
|
||||
//! the data source and the failure mode. This matches cpu-x's
|
||||
//! `MSG_VERBOSE` pattern (core.cpp:380-410) and lets the user know
|
||||
//! at a glance which paths are live vs. degraded.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use log::info;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Platform {
|
||||
/// Redox OS: `/scheme/sys/...` paths.
|
||||
@@ -131,8 +133,8 @@ fn probe_msr(platform: &Platform) -> Option<MsrBackend> {
|
||||
device_path: PathBuf::from("/scheme/sys/msr/{cpu}/0x{msr_hex}"),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source MSR (Redox): /scheme/sys/msr/0/0x19c not found; \
|
||||
info!(
|
||||
"data source MSR (Redox): /scheme/sys/msr/0/0x19c not found; \
|
||||
Pkg Temp / per-CPU Temp / P-state will read as n/a"
|
||||
);
|
||||
None
|
||||
@@ -146,8 +148,8 @@ fn probe_msr(platform: &Platform) -> Option<MsrBackend> {
|
||||
device_path: PathBuf::from("/dev/cpu/{cpu}/msr"),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source MSR (Linux): /dev/cpu/0/msr not present; \
|
||||
info!(
|
||||
"data source MSR (Linux): /dev/cpu/0/msr not present; \
|
||||
load msr kernel module for live per-CPU Temp / P-state"
|
||||
);
|
||||
None
|
||||
@@ -166,8 +168,8 @@ fn probe_acpi_pss(platform: &Platform) -> Option<AcpiPssBackend> {
|
||||
path_template: "/scheme/acpi/processor/CPU{}/pss".to_string(),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source ACPI _PSS (Redox): \
|
||||
info!(
|
||||
"data source ACPI _PSS (Redox): \
|
||||
/scheme/acpi/processor/CPU0/pss not found; \
|
||||
using hardcoded P0..P5 fallback (no real freq data)"
|
||||
);
|
||||
@@ -192,8 +194,8 @@ fn probe_acpi_pss(platform: &Platform) -> Option<AcpiPssBackend> {
|
||||
.to_string(),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source cpufreq sysfs (Linux): \
|
||||
info!(
|
||||
"data source cpufreq sysfs (Linux): \
|
||||
no scaling_available_frequencies or cpuinfo_max_freq found; \
|
||||
P-state column will read as n/a"
|
||||
);
|
||||
@@ -214,8 +216,8 @@ fn probe_load(platform: &Platform) -> Option<LoadBackend> {
|
||||
is_per_cpu: true,
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source per-CPU load (Redox): \
|
||||
info!(
|
||||
"data source per-CPU load (Redox): \
|
||||
/scheme/sys/cpu/0/stat not found; load will read 0%"
|
||||
);
|
||||
None
|
||||
@@ -229,8 +231,8 @@ fn probe_load(platform: &Platform) -> Option<LoadBackend> {
|
||||
is_per_cpu: false,
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source load (Linux): /proc/stat not found; \
|
||||
info!(
|
||||
"data source load (Linux): /proc/stat not found; \
|
||||
load will read 0%"
|
||||
);
|
||||
None
|
||||
@@ -248,8 +250,8 @@ fn probe_governor(platform: &Platform) -> Option<GovernorBackend> {
|
||||
path_template: "/scheme/cpufreq/state".to_string(),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source cpufreqd (Redox): \
|
||||
info!(
|
||||
"data source cpufreqd (Redox): \
|
||||
/scheme/cpufreq/state not found; governor read-only"
|
||||
);
|
||||
None
|
||||
@@ -262,8 +264,8 @@ fn probe_governor(platform: &Platform) -> Option<GovernorBackend> {
|
||||
.to_string(),
|
||||
})
|
||||
} else {
|
||||
eprintln!(
|
||||
"redbear-power: data source cpufreq sysfs (Linux): \
|
||||
info!(
|
||||
"data source cpufreq sysfs (Linux): \
|
||||
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor not found; \
|
||||
governor read-only"
|
||||
);
|
||||
@@ -302,8 +304,8 @@ fn probe_hwmon(platform: &Platform) -> Option<HwmonBackend> {
|
||||
}
|
||||
}
|
||||
if chips.is_empty() {
|
||||
eprintln!(
|
||||
"redbear-power: data source hwmon (Linux): no coretemp/k10temp/zenpower chip found; \
|
||||
info!(
|
||||
"data source hwmon (Linux): no coretemp/k10temp/zenpower chip found; \
|
||||
per-CPU Temp will use MSR fallback only"
|
||||
);
|
||||
None
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
//! │ 1 2400 15.0 70▏▎·· │
|
||||
//! └────────────────────────┘
|
||||
|
||||
use log::{info};
|
||||
use serde::Serialize;
|
||||
use std::io;
|
||||
|
||||
@@ -2511,7 +2512,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
print!("{}", snapshot(app, 140, 50));
|
||||
|
||||
// Also dump the System panel as a second snapshot for verification.
|
||||
eprintln!("--- System panel (verifies v1.4 memory + OS info) ---");
|
||||
info!("--- System panel (verifies v1.4 memory + OS info) ---");
|
||||
let sys_para = render_system_panel(app, false);
|
||||
let backend = TestBackend::new(120, 30);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2521,7 +2522,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Motherboard panel (verifies v1.5 DMI/SMBIOS) ---");
|
||||
info!("--- Motherboard panel (verifies v1.5 DMI/SMBIOS) ---");
|
||||
let mb_para = render_motherboard_panel(app, false);
|
||||
let backend = TestBackend::new(120, 40);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2531,7 +2532,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Battery panel (verifies v1.6 power_supply) ---");
|
||||
info!("--- Battery panel (verifies v1.6 power_supply) ---");
|
||||
let bat_para = render_battery_panel(app, false);
|
||||
let backend = TestBackend::new(120, 30);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2541,7 +2542,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Sensors panel (verifies v1.9 hwmon) ---");
|
||||
info!("--- Sensors panel (verifies v1.9 hwmon) ---");
|
||||
let sen_para = render_sensor_panel(app, false);
|
||||
let backend = TestBackend::new(120, 50);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2551,7 +2552,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Network panel (verifies v1.11 sysfs) ---");
|
||||
info!("--- Network panel (verifies v1.11 sysfs) ---");
|
||||
let net_para = render_network_panel(app, false);
|
||||
let backend = TestBackend::new(120, 60);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2561,7 +2562,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Storage panel (verifies v1.12 sysfs) ---");
|
||||
info!("--- Storage panel (verifies v1.12 sysfs) ---");
|
||||
let sto_para = render_storage_panel(app, false);
|
||||
let backend = TestBackend::new(120, 40);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2571,7 +2572,7 @@ pub fn render_once(app: &App) -> io::Result<()> {
|
||||
})
|
||||
.expect("draw");
|
||||
print!("{}", buffer_to_string(terminal.backend().buffer()));
|
||||
eprintln!("--- Process panel (verifies v1.13 procfs) ---");
|
||||
info!("--- Process panel (verifies v1.13 procfs) ---");
|
||||
let proc_para = render_process_panel(app, false);
|
||||
let backend = TestBackend::new(120, 60);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
@@ -2863,7 +2864,7 @@ fn render_graph_snapshot(
|
||||
top_label: &str,
|
||||
bot_label: &str,
|
||||
) {
|
||||
eprintln!("--- Graph:{title} ---");
|
||||
info!("--- Graph:{title} ---");
|
||||
let backend = TestBackend::new(80, GRAPH_HEIGHT);
|
||||
let mut terminal = Terminal::new(backend).expect("test terminal");
|
||||
let graph = BrailleGraph {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//! Tests live in the same file (#[cfg(test)] mod tests).
|
||||
//! v1.40.
|
||||
|
||||
use log::{warn};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::app::TabId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use anyhow::{bail, Context, Result};
|
||||
use redbear_traceroute::{
|
||||
use log::{error, info, warn};
|
||||
use redbear_traceroute::{
|
||||
destination_port, format_reply_suffix, probe, resolve_destination, ProbeStatus,
|
||||
};
|
||||
use std::env;
|
||||
@@ -146,7 +146,7 @@ fn run() -> Result<()> {
|
||||
fn main() {
|
||||
let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).try_init();
|
||||
if let Err(err) = run() {
|
||||
log::error!("redbear-traceroute: {err}"));
|
||||
log::error!("redbear-traceroute: {err}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user