64d9847e37
Linux's syslog is a local socket, so this uses the recent UDS work. * Most of redox.rs is refactored into mod.rs now which has all of the C facing functions and consts. * I wrapped the global logger in a Mutex instead of a RwLock. The logger is almost always locked for writing so a Mutex is simpler as RwLock provides no benefits. * I implemented LOG_PERROR which also prints errors to stderr as well as the log. * Syslog should be sys/syslog.h with syslog.h as an alias (the original code only had syslog.h).
26 lines
518 B
Rust
26 lines
518 B
Rust
use crate::{
|
|
error::{Errno, Result},
|
|
fs::File,
|
|
header::fcntl,
|
|
io::BufWriter,
|
|
};
|
|
|
|
use super::logger::LogSink;
|
|
|
|
/// Write logs to Redox's log scheme.
|
|
pub struct LogFile(BufWriter<File>);
|
|
|
|
impl LogSink for LogFile {
|
|
type Sink = BufWriter<File>;
|
|
|
|
#[inline(always)]
|
|
fn open() -> Result<Self> {
|
|
File::open(c"/scheme/log".into(), fcntl::O_WRONLY).map(|file| Self(BufWriter::new(file)))
|
|
}
|
|
|
|
#[inline(always)]
|
|
fn writer(&mut self) -> &mut Self::Sink {
|
|
&mut self.0
|
|
}
|
|
}
|