Crate log_buffer [] [src]

log_buffer provides a way to record and extract logs without allocation. The LogBuffer achieves this by providing a ring buffer, similar to a *nix dmesg facility.

Usage example

use std::fmt::Write;

let mut dmesg = log_buffer::LogBuffer::new([0; 16]);
write!(dmesg, "\nfirst\n").unwrap();
write!(dmesg, "second\n").unwrap();
write!(dmesg, "third\n").unwrap();

           vec!["second", "third"]);Run

Choices of backing storage

Backed by an array:

let mut dmesg = log_buffer::LogBuffer::new([0; 16]);Run

Backed by a mutable slice:

let mut storage = [0; 16];
let mut dmesg = log_buffer::LogBuffer::new(&mut storage);Run

Backed by a vector:

let mut dmesg = log_buffer::LogBuffer::new(vec![0; 16]);Run



A ring buffer that stores UTF-8 text.