log_buffer

Crates.iolog_buffer
lib.rslog_buffer
version1.2.0
sourcesrc
created_at2016-09-05 17:17:32.062229
updated_at2018-05-05 01:10:56.107177
descriptionA zero-allocation ring buffer for storing text logs
homepagehttps://github.com/whitequark/rust-log_buffer
repositoryhttps://github.com/whitequark/rust-log_buffer
max_upload_size
id6253
size22,975
whitequark (whitequark)

documentation

https://whitequark.github.io/rust-log_buffer/log_buffer

README

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.

Commit count: 15

cargo fmt