Name disk driver log files based on scheme name

This commit is contained in:
Jeremy Soller
2022-09-09 08:51:02 -06:00
parent efc5cc712d
commit ae66182c4e
3 changed files with 19 additions and 18 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ use crate::scheme::DiskScheme;
pub mod ahci;
pub mod scheme;
fn setup_logging() -> Option<&'static RedoxLogger> {
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
let mut logger = RedoxLogger::new()
.with_output(
OutputBuilder::stderr()
@@ -30,25 +30,25 @@ fn setup_logging() -> Option<&'static RedoxLogger> {
);
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", "ahci.log") {
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", &format!("{}.log", name)) {
Ok(b) => logger = logger.with_output(
// TODO: Add a configuration file for this
b.with_filter(log::LevelFilter::Info)
.flush_on_newline(true)
.build()
),
Err(error) => eprintln!("ahcid: failed to create ahci.log: {}", error),
Err(error) => eprintln!("ahcid: failed to create log: {}", error),
}
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", "ahci.ansi.log") {
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", &format!("{}.ansi.log", name)) {
Ok(b) => logger = logger.with_output(
b.with_filter(log::LevelFilter::Info)
.with_ansi_escape_codes()
.flush_on_newline(true)
.build()
),
Err(error) => eprintln!("ahcid: failed to create ahci.ansi.log: {}", error),
Err(error) => eprintln!("ahcid: failed to create ansi log: {}", error),
}
match logger.enable() {
@@ -82,7 +82,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let irq_str = args.next().expect("ahcid: no irq provided");
let irq = irq_str.parse::<u8>().expect("ahcid: failed to parse irq");
let _logger_ref = setup_logging();
let _logger_ref = setup_logging(&name);
info!(" + AHCI {} on: {:X} size: {} IRQ: {}", name, bar, bar_size, irq);
+2 -1
View File
@@ -80,12 +80,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
PcidServerHandle::connect_default().expect("ided: failed to setup channel to pcid");
let pci_config = pcid_handle.fetch_config().expect("ided: failed to fetch config");
let mut name = pci_config.func.name();
name.push_str("_ide");
let _logger_ref = setup_logging(&name);
info!("IDE {:?}", pci_config);
info!("IDE PCI CONFIG: {:?}", pci_config);
let pci_header = pcid_handle.fetch_header().expect("ided: failed to fetch PCI header");
let (primary, primary_irq) = if pci_header.interface() & 1 != 0 {
+11 -11
View File
@@ -239,36 +239,36 @@ fn get_int_method(
}
}
fn setup_logging() -> Option<&'static RedoxLogger> {
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
let mut logger = RedoxLogger::new()
.with_output(
OutputBuilder::stderr()
.with_filter(log::LevelFilter::Debug) // limit global output to important info
.with_filter(log::LevelFilter::Info) // limit global output to important info
.with_ansi_escape_codes()
.flush_on_newline(true)
.build()
);
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", "nvme.log") {
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", &format!("{}.log", name)) {
Ok(b) => logger = logger.with_output(
// TODO: Add a configuration file for this
b.with_filter(log::LevelFilter::Info)
.flush_on_newline(true)
.build()
),
Err(error) => eprintln!("nvmed: failed to create nvme.log: {}", error),
Err(error) => eprintln!("nvmed: failed to create log: {}", error),
}
#[cfg(target_os = "redox")]
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", "nvme.ansi.log") {
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", &format!("{}.ansi.log", name)) {
Ok(b) => logger = logger.with_output(
b.with_filter(log::LevelFilter::Info)
.with_ansi_escape_codes()
.flush_on_newline(true)
.build()
),
Err(error) => eprintln!("nvmed: failed to create nvme.ansi.log: {}", error),
Err(error) => eprintln!("nvmed: failed to create ansi log: {}", error),
}
match logger.enable() {
@@ -287,14 +287,17 @@ fn main() {
redox_daemon::Daemon::new(daemon).expect("nvmed: failed to daemonize");
}
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let _logger_ref = setup_logging();
let mut pcid_handle =
PcidServerHandle::connect_default().expect("nvmed: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("nvmed: failed to fetch config");
let mut name = pci_config.func.name();
name.push_str("_nvme");
let _logger_ref = setup_logging(&name);
let bar = match pci_config.func.bars[0] {
PciBar::Memory32(mem) => match mem {
0 => panic!("BAR 0 is mapped to address 0"),
@@ -309,9 +312,6 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let bar_size = pci_config.func.bar_sizes[0];
let irq = pci_config.func.legacy_interrupt_line;
let mut name = pci_config.func.name();
name.push_str("_nvme");
log::info!("NVME PCI CONFIG: {:?}", pci_config);
let allocated_bars = AllocatedBars::default();