#log #buffer #ring #std #logging #storage #text #logs

log_buffer

A zero-allocation ring buffer for storing text logs

4 releases (stable)

Uses old Rust 2015

1.2.0 May 5, 2018
1.1.0 Oct 2, 2016
1.0.0 Sep 5, 2016
0.1.0 Sep 5, 2016
Download history 120/week @ 2022-08-08 95/week @ 2022-08-15 65/week @ 2022-08-22 93/week @ 2022-08-29 63/week @ 2022-09-05 63/week @ 2022-09-12 75/week @ 2022-09-19 54/week @ 2022-09-26 60/week @ 2022-10-03 64/week @ 2022-10-10 61/week @ 2022-10-17 64/week @ 2022-10-24 72/week @ 2022-10-31 63/week @ 2022-11-07 72/week @ 2022-11-14 58/week @ 2022-11-21

270 downloads per month
Used in coap-message-demos

MIT/Apache

9KB
68 lines

log_buffer

log_buffer is a Rust crate implementing a zero-allocation ring buffer for storing text logs. It does not depend on std, but can be used with std::vec::Vec if desired. It does not depend on anything and compiles on Rust 1.26 or newer.

See the documentation for details.

Installation

To use the log_buffer library in your project, add the following to Cargo.toml:

[dependencies]
log_buffer = "1.0"

Usage example

use core::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();

assert_eq!(dmesg.extract(),
           "st\nsecond\nthird\n");
assert_eq!(dmesg.extract_lines().collect::<Vec<_>>(),
           vec!["second", "third"]);

See the documentation for more examples.

License

log_buffer is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

No runtime deps

Features

  • const_fn