Deduplicate setup_logging between all drivers
This will make it easier to change the way logging is done for all drivers. This also fixes the log category for a couple of drivers as well as makes failing to set the logger a fatal error. Only when a logger is already set is it impossible to set another logger.
This commit is contained in:
Generated
+6
-17
@@ -12,7 +12,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
"spin",
|
||||
@@ -32,7 +31,6 @@ dependencies = [
|
||||
"parking_lot 0.11.2",
|
||||
"plain",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
"rustc-hash",
|
||||
"serde_json",
|
||||
@@ -51,7 +49,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox-scheme",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
@@ -286,6 +283,8 @@ name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libredox 0.1.3",
|
||||
"log",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
]
|
||||
|
||||
@@ -590,7 +589,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox-scheme",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
@@ -606,7 +604,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
"spin",
|
||||
@@ -627,11 +624,11 @@ name = "inputd"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"common",
|
||||
"libredox 0.1.3",
|
||||
"log",
|
||||
"orbclient",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
"spin",
|
||||
]
|
||||
@@ -789,7 +786,6 @@ dependencies = [
|
||||
"partitionlib",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox-scheme",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
@@ -938,7 +934,6 @@ dependencies = [
|
||||
"pci_types",
|
||||
"plain",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1012,11 +1007,11 @@ name = "ps2d"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"common",
|
||||
"libredox 0.1.3",
|
||||
"log",
|
||||
"orbclient",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
]
|
||||
|
||||
@@ -1176,7 +1171,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
]
|
||||
@@ -1192,7 +1186,6 @@ dependencies = [
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
]
|
||||
@@ -1218,7 +1211,6 @@ dependencies = [
|
||||
"libredox 0.1.3",
|
||||
"log",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
"spin",
|
||||
@@ -1544,9 +1536,9 @@ name = "usbhidd"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"common",
|
||||
"log",
|
||||
"orbclient",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
"rehid",
|
||||
"xhcid",
|
||||
@@ -1556,8 +1548,8 @@ dependencies = [
|
||||
name = "usbhubd"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"common",
|
||||
"log",
|
||||
"redox-log",
|
||||
"redox_syscall 0.5.3",
|
||||
"xhcid",
|
||||
]
|
||||
@@ -1654,7 +1646,6 @@ dependencies = [
|
||||
"partitionlib",
|
||||
"pcid",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox-scheme",
|
||||
"redox_syscall 0.5.3",
|
||||
"spin",
|
||||
@@ -1674,7 +1665,6 @@ dependencies = [
|
||||
"libredox 0.1.3",
|
||||
"log",
|
||||
"pcid",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
"static_assertions",
|
||||
@@ -1914,7 +1904,6 @@ dependencies = [
|
||||
"pcid",
|
||||
"plain",
|
||||
"redox-daemon",
|
||||
"redox-log",
|
||||
"redox_event",
|
||||
"redox_syscall 0.5.3",
|
||||
"serde",
|
||||
|
||||
@@ -14,7 +14,6 @@ num-traits = "0.2"
|
||||
parking_lot = "0.11.1"
|
||||
plain = "0.2.3"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1.1"
|
||||
redox_syscall = "0.5"
|
||||
rustc-hash = "1.1.0"
|
||||
thiserror = "1"
|
||||
|
||||
+7
-49
@@ -8,7 +8,6 @@ use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
|
||||
use std::sync::Arc;
|
||||
|
||||
use redox_log::RedoxLogger;
|
||||
use syscall::scheme::SchemeMut;
|
||||
|
||||
use syscall::data::{Event, Packet};
|
||||
@@ -31,55 +30,14 @@ fn monotonic() -> (u64, u64) {
|
||||
(timespec.tv_sec as u64, timespec.tv_nsec as u64)
|
||||
}
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
use redox_log::OutputBuilder;
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("misc", "acpi", "acpid.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
// TODO: Add a configuration file for this
|
||||
b.with_filter(log::LevelFilter::Warn)
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create acpid.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("misc", "acpi", "acpid.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Warn)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create acpid.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("acpid: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("acpid: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
setup_logging();
|
||||
common::setup_logging(
|
||||
"misc",
|
||||
"acpi",
|
||||
"acpid",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Warn,
|
||||
);
|
||||
|
||||
let rxsdt_raw_data: Arc<[u8]> = std::fs::read("/scheme/kernel.acpi/rxsdt")
|
||||
.expect("acpid: failed to read `/scheme/kernel.acpi/rxsdt`")
|
||||
|
||||
@@ -9,7 +9,6 @@ common = { path = "../../common" }
|
||||
libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1.2"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
spin = "0.9"
|
||||
|
||||
+7
-46
@@ -15,55 +15,10 @@ use std::usize;
|
||||
use event::{user_data, EventQueue};
|
||||
use libredox::flag;
|
||||
use pcid_interface::{PciBar, PciFunctionHandle};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use syscall::{EventFlags, Packet, SchemeBlockMut};
|
||||
|
||||
pub mod device;
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("audio", "pcie", "ac97.log") {
|
||||
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!("ac97d: failed to create ac97.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("audio", "pcie", "ac97.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("ac97d: failed to create ac97.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("ac97d: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("ac97d: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let pcid_handle =
|
||||
PciFunctionHandle::connect_default().expect("ac97d: failed to setup channel to pcid");
|
||||
@@ -81,7 +36,13 @@ fn main() {
|
||||
|
||||
// Daemonize
|
||||
redox_daemon::Daemon::new(move |daemon| {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"audio",
|
||||
"pcie",
|
||||
"ac97",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
common::acquire_port_io_rights().expect("ac97d: failed to set I/O privilege level to Ring 3");
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ bitflags = "2"
|
||||
libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1.2"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
spin = "0.9"
|
||||
|
||||
+7
-46
@@ -20,7 +20,6 @@ use pcid_interface::{MsiSetFeatureInfo, PciFunctionHandle, PciFeature, PciFeatur
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
|
||||
use pcid_interface::irq_helpers::read_bsp_apic_id;
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
pub mod hda;
|
||||
|
||||
@@ -31,50 +30,6 @@ pub mod hda;
|
||||
82801H ICH8 8086:284B
|
||||
*/
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.with_filter(log::LevelFilter::Debug) // 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("audio", "pcie", "ihda.log") {
|
||||
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!("ihdad: failed to create ihda.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("audio", "pcie", "ihda.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("ihdad: failed to create ihda.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("ihdad: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("ihdad: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
|
||||
let pci_config = pcid_handle.config();
|
||||
@@ -133,7 +88,13 @@ fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
|
||||
}
|
||||
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"audio",
|
||||
"pcie",
|
||||
"ihda",
|
||||
log::LevelFilter::Debug,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default().expect("ihdad: failed to setup channel to pcid");
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ common = { path = "../../common" }
|
||||
libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1.2"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
spin = "0.9"
|
||||
|
||||
+7
-46
@@ -6,54 +6,9 @@ use libredox::{flag, Fd};
|
||||
use syscall::{Packet, SchemeBlockMut};
|
||||
|
||||
use event::{user_data, EventQueue};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
pub mod device;
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("audio", "pcie", "sb16.log") {
|
||||
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!("sb16d: failed to create sb16.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("audio", "pcie", "sb16.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("sb16d: failed to create sb16.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("sb16d: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("sb16d: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut args = env::args().skip(1);
|
||||
|
||||
@@ -64,7 +19,13 @@ fn main() {
|
||||
|
||||
// Daemonize
|
||||
redox_daemon::Daemon::new(move |daemon| {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"audio",
|
||||
"pcie",
|
||||
"sb16",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
common::acquire_port_io_rights().expect("sb16d: failed to acquire port IO rights");
|
||||
|
||||
|
||||
@@ -9,4 +9,6 @@ license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
redox_syscall = "0.5"
|
||||
redox-log = "0.1.2"
|
||||
|
||||
@@ -6,8 +6,11 @@ use libredox::{errno::EINVAL, error::*, Fd};
|
||||
use syscall::PAGE_SIZE;
|
||||
|
||||
pub mod dma;
|
||||
mod logger;
|
||||
pub mod sgl;
|
||||
|
||||
pub use logger::setup_logging;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum MemoryType {
|
||||
Writeback,
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
#[cfg_attr(not(target_os = "redox"), allow(unused_variables, unused_mut))]
|
||||
pub fn setup_logging(
|
||||
category: &str,
|
||||
subcategory: &str,
|
||||
logfile_base: &str,
|
||||
output_level: log::LevelFilter,
|
||||
file_level: log::LevelFilter,
|
||||
) {
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.with_filter(output_level) // 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(
|
||||
category,
|
||||
subcategory,
|
||||
format!("{logfile_base}.log"),
|
||||
) {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(b.with_filter(file_level).flush_on_newline(true).build())
|
||||
}
|
||||
Err(error) => eprintln!("Failed to create {logfile_base}.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme(
|
||||
category,
|
||||
subcategory,
|
||||
format!("{logfile_base}.ansi.log"),
|
||||
) {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(
|
||||
b.with_filter(file_level)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(error) => eprintln!("Failed to create {logfile_base}.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
logger.enable().expect("failed to set default logger");
|
||||
}
|
||||
@@ -466,7 +466,12 @@ fn daemon_runner(redox_daemon: redox_daemon::Daemon) -> ! {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
#[cfg(target_os = "redox")]
|
||||
virtio_core::utils::setup_logging(log::LevelFilter::Trace, "virtio-gpud");
|
||||
common::setup_logging(
|
||||
"misc",
|
||||
"pcie",
|
||||
"virtio-gpud",
|
||||
log::LevelFilter::Trace,
|
||||
log::LevelFilter::Trace,
|
||||
);
|
||||
redox_daemon::Daemon::new(daemon_runner).expect("virtio-core: failed to daemonize");
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,8 +8,9 @@ authors = ["Anhad Singh <andypython@protonmail.com>"]
|
||||
anyhow = "1.0.71"
|
||||
log = "0.4.19"
|
||||
redox-daemon = "0.1.2"
|
||||
redox-log = "0.1.1"
|
||||
redox_syscall = "0.5"
|
||||
orbclient = "0.3.27"
|
||||
spin = "0.9.8"
|
||||
libredox = "0.1.3"
|
||||
|
||||
common = { path = "../common" }
|
||||
|
||||
+7
-38
@@ -427,45 +427,14 @@ fn daemon_runner(redox_daemon: redox_daemon::Daemon) -> ! {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
pub fn setup_logging(level: log::LevelFilter, name: &str) {
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.with_filter(level)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
);
|
||||
|
||||
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", format!("{name}.log")) {
|
||||
Ok(builder) => {
|
||||
logger = logger.with_output(builder.with_filter(level).flush_on_newline(true).build())
|
||||
}
|
||||
Err(err) => eprintln!("inputd: failed to create log: {}", err),
|
||||
}
|
||||
|
||||
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", format!("{name}.ansi.log")) {
|
||||
Ok(builder) => {
|
||||
logger = logger.with_output(
|
||||
builder
|
||||
.with_filter(level)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(err) => eprintln!("inputd: failed to create ANSI log: {}", err),
|
||||
}
|
||||
|
||||
logger.enable().unwrap();
|
||||
log::info!("inputd: enabled logger");
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
#[cfg(target_os = "redox")]
|
||||
setup_logging(log::LevelFilter::Trace, "inputd");
|
||||
common::setup_logging(
|
||||
"misc",
|
||||
"inputd",
|
||||
"inputd",
|
||||
log::LevelFilter::Trace,
|
||||
log::LevelFilter::Trace,
|
||||
);
|
||||
|
||||
let mut args = std::env::args().skip(1);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ log = "0.4"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
|
||||
common = { path = "../../common" }
|
||||
driver-network = { path = "../driver-network" }
|
||||
|
||||
@@ -18,55 +18,10 @@ use pcid_interface::{
|
||||
MsiSetFeatureInfo, PciFeature, PciFeatureInfo, PciFunctionHandle, SetFeatureInfo,
|
||||
SubdriverArguments,
|
||||
};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use syscall::EventFlags;
|
||||
|
||||
pub mod device;
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("net", "pcie", "rtl8139.log") {
|
||||
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!("Failed to create rtl8139.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("net", "pcie", "rtl8139.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create rtl8139.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("rtl8139d: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("rtl8139d: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use std::ops::{Add, Div, Rem};
|
||||
pub fn div_round_up<T>(a: T, b: T) -> T
|
||||
where
|
||||
@@ -208,7 +163,13 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> {
|
||||
}
|
||||
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"net",
|
||||
"pcie",
|
||||
"rtl8139",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default().expect("rtl8139d: failed to setup channel to pcid");
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ log = "0.4"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
|
||||
common = { path = "../../common" }
|
||||
driver-network = { path = "../driver-network" }
|
||||
|
||||
@@ -13,55 +13,10 @@ use pcid_interface::{MsiSetFeatureInfo, PciFunctionHandle, PciFeature, PciFeatur
|
||||
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
|
||||
use pcid_interface::irq_helpers::read_bsp_apic_id;
|
||||
use pcid_interface::msi::{MsixInfo, MsixTableEntry};
|
||||
use redox_log::{RedoxLogger, OutputBuilder};
|
||||
use syscall::EventFlags;
|
||||
|
||||
pub mod device;
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("net", "pcie", "rtl8168.log") {
|
||||
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!("Failed to create rtl8168.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("net", "pcie", "rtl8168.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create rtl8168.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("rtl8168d: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("rtl8168d: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use std::ops::{Add, Div, Rem};
|
||||
pub fn div_round_up<T>(a: T, b: T) -> T
|
||||
where
|
||||
@@ -203,7 +158,13 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> {
|
||||
}
|
||||
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"net",
|
||||
"pcie",
|
||||
"rtl8168",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
let mut pcid_handle = PciFunctionHandle::connect_default().expect("rtl8168d: failed to setup channel to pcid");
|
||||
|
||||
|
||||
@@ -120,7 +120,12 @@ fn daemon_runner(redox_daemon: redox_daemon::Daemon) -> ! {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
#[cfg(target_os = "redox")]
|
||||
virtio_core::utils::setup_logging(log::LevelFilter::Trace, "virtio-netd");
|
||||
common::setup_logging(
|
||||
"net",
|
||||
"pcie",
|
||||
"virtio-netd",
|
||||
log::LevelFilter::Trace,
|
||||
log::LevelFilter::Trace,
|
||||
);
|
||||
redox_daemon::Daemon::new(daemon_runner).expect("virtio-core: failed to daemonize");
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ paw = "1.0"
|
||||
pci_types = "0.10"
|
||||
plain = "0.2"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = "0.5"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
+7
-53
@@ -10,7 +10,6 @@ use pci_types::{
|
||||
Bar as TyBar, CommandRegister, EndpointHeader, HeaderType, PciAddress,
|
||||
PciHeader as TyPciHeader, PciPciBridgeHeader,
|
||||
};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use structopt::StructOpt;
|
||||
|
||||
use crate::cfg_access::Pcie;
|
||||
@@ -166,57 +165,6 @@ fn handle_parsed_header(
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_logging(verbosity: u8) -> Option<&'static RedoxLogger> {
|
||||
let log_level = match verbosity {
|
||||
0 => log::LevelFilter::Info,
|
||||
1 => log::LevelFilter::Debug,
|
||||
_ => log::LevelFilter::Trace,
|
||||
};
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.with_ansi_escape_codes()
|
||||
.with_filter(log_level)
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
);
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
{
|
||||
match OutputBuilder::in_redox_logging_scheme("bus", "pci", "pcid.log") {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Trace)
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(error) => eprintln!("pcid: failed to open pcid.log"),
|
||||
}
|
||||
match OutputBuilder::in_redox_logging_scheme("bus", "pci", "pcid.ansi.log") {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Trace)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(error) => eprintln!("pcid: failed to open pcid.ansi.log"),
|
||||
}
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("pcid: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("pcid: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[paw::main]
|
||||
fn main(args: Args) {
|
||||
let mut config = Config::default();
|
||||
@@ -246,7 +194,13 @@ fn main(args: Args) {
|
||||
}
|
||||
}
|
||||
|
||||
let _logger_ref = setup_logging(args.verbose);
|
||||
let log_level = match args.verbose {
|
||||
0 => log::LevelFilter::Info,
|
||||
1 => log::LevelFilter::Debug,
|
||||
_ => log::LevelFilter::Trace,
|
||||
};
|
||||
|
||||
common::setup_logging("bus", "pci", "pcid", log_level, log::LevelFilter::Trace);
|
||||
|
||||
redox_daemon::Daemon::new(move |daemon| main_inner(config, daemon)).unwrap();
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,5 +9,6 @@ log = "0.4"
|
||||
orbclient = "0.3.27"
|
||||
redox_syscall = "0.5"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1.1"
|
||||
libredox = "0.1.3"
|
||||
|
||||
common = { path = "../common" }
|
||||
|
||||
+7
-46
@@ -12,7 +12,6 @@ use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
use log::info;
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use syscall::call::iopl;
|
||||
|
||||
use crate::state::Ps2d;
|
||||
@@ -23,52 +22,14 @@ mod state;
|
||||
mod vm;
|
||||
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("misc", "ps2", "ps2.log") {
|
||||
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!("ps2d: failed to create ps2.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("misc", "ps2", "ps2.ansi.log") {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("ps2d: failed to create ps2.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("ps2d: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("ps2d: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
setup_logging();
|
||||
common::setup_logging(
|
||||
"misc",
|
||||
"ps2",
|
||||
"ps2",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
unsafe {
|
||||
iopl(3).expect("ps2d: failed to get I/O permission");
|
||||
|
||||
@@ -8,7 +8,6 @@ bitflags = "1.2"
|
||||
byteorder = "1.2"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = { version = "0.5", features = ["std"] }
|
||||
|
||||
common = { path = "../../common" }
|
||||
|
||||
@@ -14,7 +14,6 @@ use redox_scheme::{RequestKind, Response, SignalBehavior, Socket, V2};
|
||||
use syscall::error::{Error, ENODEV};
|
||||
|
||||
use log::{error, info};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use syscall::{EAGAIN, EWOULDBLOCK};
|
||||
|
||||
use crate::scheme::DiskScheme;
|
||||
@@ -22,50 +21,6 @@ use crate::scheme::DiskScheme;
|
||||
pub mod ahci;
|
||||
pub mod scheme;
|
||||
|
||||
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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", &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 log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
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 ansi log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("ahcid: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("ahcid: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
redox_daemon::Daemon::new(daemon).expect("ahcid: failed to daemonize");
|
||||
}
|
||||
@@ -80,7 +35,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
|
||||
let irq = pci_config.func.legacy_interrupt_line.expect("ahcid: no legacy interrupts supported");
|
||||
|
||||
let _logger_ref = setup_logging(&name);
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pcie",
|
||||
&name,
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
info!(" + AHCI {}", pci_config.func.display());
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
pcid = { path = "../../pcid" }
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = { version = "0.5", features = ["std"] }
|
||||
redox-scheme = { git = "https://gitlab.redox-os.org/redox-os/redox-scheme.git" }
|
||||
redox_event = "0.4"
|
||||
|
||||
@@ -3,7 +3,6 @@ use event::{EventFlags, RawEventQueue};
|
||||
use libredox::flag;
|
||||
use log::{error, info};
|
||||
use pcid_interface::{PciBar, PciFunctionHandle};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use redox_scheme::{RequestKind, Response, SignalBehavior, Socket, V2};
|
||||
use std::{
|
||||
fs::File,
|
||||
@@ -25,50 +24,6 @@ use crate::{
|
||||
pub mod ide;
|
||||
pub mod scheme;
|
||||
|
||||
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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", &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!("ided: failed to create log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
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!("ided: failed to create ansi log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("ided: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("ided: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
redox_daemon::Daemon::new(daemon).expect("ided: failed to daemonize");
|
||||
}
|
||||
@@ -82,7 +37,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
let mut name = pci_config.func.name();
|
||||
name.push_str("_ide");
|
||||
|
||||
let _logger_ref = setup_logging(&name);
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pcie",
|
||||
&name,
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
info!("IDE PCI CONFIG: {:?}", pci_config);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ crossbeam-channel = "0.4"
|
||||
futures = "0.3"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = { version = "0.5", features = ["std"] }
|
||||
redox-scheme = { git = "https://gitlab.redox-os.org/redox-os/redox-scheme.git" }
|
||||
redox_event = "0.4"
|
||||
|
||||
@@ -16,7 +16,6 @@ use syscall::{
|
||||
Event, Mmio, Packet, Result, SchemeBlockMut,
|
||||
PAGE_SIZE,
|
||||
};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
use self::nvme::{InterruptMethod, InterruptSources, Nvme};
|
||||
use self::scheme::DiskScheme;
|
||||
@@ -151,50 +150,6 @@ fn get_int_method(
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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", &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 log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
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 ansi log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("nvmed: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("nvmed: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
redox_daemon::Daemon::new(daemon).expect("nvmed: failed to daemonize");
|
||||
}
|
||||
@@ -205,7 +160,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
|
||||
let scheme_name = format!("disk.{}-nvme", pci_config.func.name());
|
||||
|
||||
let _logger_ref = setup_logging(&scheme_name);
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pcie",
|
||||
&scheme_name,
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
log::debug!("NVME PCI CONFIG: {:?}", pci_config);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ futures = { version = "0.3.28", features = ["executor"] }
|
||||
spin = "*"
|
||||
|
||||
redox-daemon = "0.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = { version = "0.5", features = ["std"] }
|
||||
redox-scheme = { git = "https://gitlab.redox-os.org/redox-os/redox-scheme.git" }
|
||||
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
|
||||
|
||||
@@ -35,8 +35,13 @@ pub enum Error {
|
||||
}
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
#[cfg(target_os = "redox")]
|
||||
virtio_core::utils::setup_logging(log::LevelFilter::Trace, "virtio-blkd");
|
||||
common::setup_logging(
|
||||
"disk",
|
||||
"pcie",
|
||||
"virtio-blkd",
|
||||
log::LevelFilter::Trace,
|
||||
log::LevelFilter::Trace,
|
||||
);
|
||||
redox_daemon::Daemon::new(daemon_runner).expect("virtio-core: failed to daemonize");
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ license = "MIT"
|
||||
bitflags = "2"
|
||||
log = "0.4"
|
||||
orbclient = "0.3.47"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = "0.5"
|
||||
rehid = { git = "https://gitlab.redox-os.org/redox-os/rehid.git" }
|
||||
xhcid = { path = "../xhcid" }
|
||||
|
||||
common = { path = "../common" }
|
||||
|
||||
+7
-49
@@ -4,7 +4,6 @@ use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use orbclient::KeyEvent as OrbKeyEvent;
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use rehid::{
|
||||
report_desc::{self, ReportTy, REPORT_DESC_TY},
|
||||
report_handler::ReportHandler,
|
||||
@@ -15,53 +14,6 @@ use xhcid_interface::{ConfigureEndpointsReq, DevDesc, EndpDirection, EndpointTy,
|
||||
mod keymap;
|
||||
mod reqs;
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("usb", "device", "hid.log") {
|
||||
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!("Failed to create hid.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("usb", "device", "hid.ansi.log") {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(error) => eprintln!("Failed to create hid.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("usbhidd: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("usbhidd: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn send_key_event(
|
||||
display: &mut File,
|
||||
usage_page: u32,
|
||||
@@ -214,7 +166,13 @@ fn send_key_event(
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"usb",
|
||||
"device",
|
||||
"hid",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
let mut args = env::args().skip(1);
|
||||
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = "0.5"
|
||||
xhcid = { path = "../xhcid" }
|
||||
|
||||
common = { path = "../common" }
|
||||
|
||||
+7
-49
@@ -3,58 +3,16 @@ use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
use xhcid_interface::{plain, usb, ConfigureEndpointsReq, DevDesc, DeviceReqData, EndpDirection, EndpointTy, PortReqRecipient, PortReqTy, XhciClientHandle};
|
||||
|
||||
fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("usb", "device", "hub.log") {
|
||||
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!("Failed to create hub.log: {}", error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("usb", "device", "hub.ansi.log") {
|
||||
Ok(b) => {
|
||||
logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Info)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(error) => eprintln!("Failed to create hub.ansi.log: {}", error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("usbhubd: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("usbhubd: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _logger_ref = setup_logging();
|
||||
common::setup_logging(
|
||||
"usb",
|
||||
"device",
|
||||
"hub",
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
let mut args = env::args().skip(1);
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ thiserror = "1.0.40"
|
||||
futures = { version = "0.3.28", features = ["executor"] }
|
||||
crossbeam-queue = "0.3.8"
|
||||
|
||||
redox-log = "0.1"
|
||||
redox_event = "0.4.1"
|
||||
|
||||
common = { path = "../common" }
|
||||
|
||||
@@ -78,39 +78,3 @@ pub const fn align(val: usize, align: usize) -> usize {
|
||||
pub const fn align_down(addr: usize) -> usize {
|
||||
addr & !(syscall::PAGE_SIZE - 1)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
pub fn setup_logging(level: log::LevelFilter, name: &str) {
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
let mut logger = RedoxLogger::new().with_output(
|
||||
OutputBuilder::stderr()
|
||||
.with_filter(level)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
);
|
||||
|
||||
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", format!("{name}.log")) {
|
||||
Ok(builder) => {
|
||||
logger = logger.with_output(builder.with_filter(level).flush_on_newline(true).build())
|
||||
}
|
||||
Err(err) => eprintln!("virtio-core::utils: failed to create log: {}", err),
|
||||
}
|
||||
|
||||
match OutputBuilder::in_redox_logging_scheme("disk", "pcie", format!("{name}.ansi.log")) {
|
||||
Ok(builder) => {
|
||||
logger = logger.with_output(
|
||||
builder
|
||||
.with_filter(level)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
Err(err) => eprintln!("virtio-core::utils: failed to create ANSI log: {}", err),
|
||||
}
|
||||
|
||||
logger.enable().unwrap();
|
||||
log::info!("virtio-core::utils: enabled logger");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ lazy_static = "1.4"
|
||||
log = "0.4"
|
||||
redox-daemon = "0.1"
|
||||
redox_event = "0.4.1"
|
||||
redox-log = "0.1"
|
||||
redox_syscall = "0.5"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
+7
-46
@@ -19,7 +19,6 @@ use pcid_interface::irq_helpers::read_bsp_apic_id;
|
||||
use pcid_interface::msi::MsixTableEntry;
|
||||
|
||||
use event::{Event, RawEventQueue};
|
||||
use redox_log::{RedoxLogger, OutputBuilder};
|
||||
use syscall::data::Packet;
|
||||
use syscall::error::EWOULDBLOCK;
|
||||
use syscall::flag::EventFlags;
|
||||
@@ -40,50 +39,6 @@ async fn handle_packet(hci: Arc<Xhci>, packet: Packet) -> Packet {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn setup_logging(name: &str) -> Option<&'static RedoxLogger> {
|
||||
let mut logger = RedoxLogger::new()
|
||||
.with_output(
|
||||
OutputBuilder::stderr()
|
||||
.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("usb", "host", &format!("{}.log", name)) {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
// TODO: Add a configuration file for this
|
||||
b.with_filter(log::LevelFilter::Debug)
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create {}.log: {}", name, error),
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
match OutputBuilder::in_redox_logging_scheme("usb", "host", &format!("{}.ansi.log", name)) {
|
||||
Ok(b) => logger = logger.with_output(
|
||||
b.with_filter(log::LevelFilter::Debug)
|
||||
.with_ansi_escape_codes()
|
||||
.flush_on_newline(true)
|
||||
.build()
|
||||
),
|
||||
Err(error) => eprintln!("Failed to create {}.ansi.log: {}", name, error),
|
||||
}
|
||||
|
||||
match logger.enable() {
|
||||
Ok(logger_ref) => {
|
||||
eprintln!("xhcid: enabled logger");
|
||||
Some(logger_ref)
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("xhcid: failed to set default logger: {}", error);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn get_int_method(pcid_handle: &mut PciFunctionHandle, bar0_address: usize) -> (Option<File>, InterruptMethod) {
|
||||
let pci_config = pcid_handle.config();
|
||||
@@ -191,7 +146,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
let mut name = pci_config.func.name();
|
||||
name.push_str("_xhci");
|
||||
|
||||
let _logger_ref = setup_logging(&name);
|
||||
common::setup_logging(
|
||||
"usb",
|
||||
"host",
|
||||
&name,
|
||||
log::LevelFilter::Info,
|
||||
log::LevelFilter::Debug,
|
||||
);
|
||||
|
||||
log::debug!("XHCI PCI CONFIG: {:?}", pci_config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user