Bug: 191700800

Clone this repo:
  1. 1511175 Migrate to cargo_embargo. by Andrew Walbran · 4 weeks ago main master
  2. d8ba481 Make kernlog available to product and vendor am: 88e5a784df am: c970024909 am: c80cad0607 by Matthew Maurer · 9 months ago android14-dev
  3. c80cad0 Make kernlog available to product and vendor am: 88e5a784df am: c970024909 by Matthew Maurer · 9 months ago
  4. c970024 Make kernlog available to product and vendor am: 88e5a784df by Matthew Maurer · 9 months ago android-u-beta-1-gpl
  5. 88e5a78 Make kernlog available to product and vendor by Matthew Maurer · 9 months ago

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.