Skip to content

A zero-allocation ring buffer for storing text logs, implemented in Rust

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT
Notifications You must be signed in to change notification settings

ESALP/rust-log_buffer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 else either.

This is a fork of the original repository by whitequark, intended to make the buffer 1) interior mutable, and 2) thread-safe.

See the documentation for details.

Installation

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

[dependencies.log_buffer]
git = https://github.com/ESALP/rust-log_buffer.git

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.

About

A zero-allocation ring buffer for storing text logs, implemented in Rust

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%