https://github.com/whitequark/rust-log_buffer
A zero-allocation ring buffer for storing text logs, implemented in Rust
https://github.com/whitequark/rust-log_buffer
Last synced: 3 months ago
JSON representation
A zero-allocation ring buffer for storing text logs, implemented in Rust
- Host: GitHub
- URL: https://github.com/whitequark/rust-log_buffer
- Owner: whitequark
- License: apache-2.0
- Created: 2016-09-05T16:34:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T02:20:39.000Z (about 2 years ago)
- Last Synced: 2025-03-11T04:53:51.052Z (3 months ago)
- Language: Rust
- Size: 561 KB
- Stars: 51
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
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][doc] for details.
[doc]: https://whitequark.github.io/rust-log_buffer/log_buffer/
Installation
------------To use the _log_buffer_ library in your project, add the following to `Cargo.toml`:
```toml
[dependencies]
log_buffer = "1.0"
```Usage example
-------------```rust
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!["second", "third"]);
```See the [documentation][doc] 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](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT)
for details.