7 releases

0.3.1 Sep 6, 2020
0.3.0 Sep 6, 2020
0.2.1 Dec 28, 2015
0.2.0 Jul 8, 2015
0.1.2 Jul 4, 2015

#248 in Debugging

Download history 1935/week @ 2024-07-25 1854/week @ 2024-08-01 1526/week @ 2024-08-08 1602/week @ 2024-08-15 1887/week @ 2024-08-22 1687/week @ 2024-08-29 2207/week @ 2024-09-05 2169/week @ 2024-09-12 2034/week @ 2024-09-19 1730/week @ 2024-09-26 1847/week @ 2024-10-03 1879/week @ 2024-10-10 1928/week @ 2024-10-17 2021/week @ 2024-10-24 1584/week @ 2024-10-31 1676/week @ 2024-11-07

7,549 downloads per month
Used in 2 crates

MIT license

7KB
107 lines

Kernel logger for Rust

Logger implementation for low level kernel log (using /dev/kmsg)

Usually intended for low level implementations, like systemd generators, which have to use /dev/kmsg:

Since syslog is not available (see above) write log messages to /dev/kmsg instead.

Full documentation.

Usage

[dependencies]
log = "0.4"
kernlog = "0.3"
#[macro_use]
extern crate log;
extern crate kernlog;

fn main() {
    kernlog::init().unwrap();
    warn!("something strange happened");
}

Note you have to have permissions to write to /dev/kmsg, which normal users (not root) usually don't.


lib.rs:

Logger implementation for low level kernel log (using /dev/kmsg)

Usually intended for low level implementations, like systemd generators, which have to use /dev/kmsg:

Since syslog is not available (see above) write log messages to /dev/kmsg instead.

Examples

[dependencies]
log = "0.4"
kernlog = "0.3"
#[macro_use]
extern crate log;
extern crate kernlog;

fn main() {
    kernlog::init().unwrap();
    warn!("something strange happened");
}

Note you have to have permissions to write to /dev/kmsg, which normal users (not root) usually don't.

If compiled with nightly it can use libc feature to get process id and report it into log. This feature is unavailable for stable release for now. To enable nightly features, compile with --features nightly:

[dependencies.kernlog]
version = "*"
features = ["nightly"]

Dependencies

~130KB