28 releases (16 stable)
7.1.0 | Oct 15, 2024 |
---|---|
7.0.0 | Nov 6, 2022 |
6.0.0 | Nov 4, 2022 |
5.0.2 | Oct 3, 2022 |
0.2.3 | Jul 30, 2020 |
#382 in Debugging
1,040 downloads per month
75KB
2K
SLoC
ll - Logging Library
ll is a lightweight logging library. Its main focus is to provide the ability to manually instrument portions of code to track and log its execution.
Instrumentation of the code is done by wrapping parts of code into Tasks
.
Tasks emit a start
event when the task is started and end
event when it's finished.
These events are consumed by Reporters
. Multiple reporters can be used at the same time
and they will each receive task events. Different reporters can report/log task events to
different systems/sources, e.g. print them to STDOUT, write to a database, file or
third-party system.
Tasks are organized in a task tree. Each task can spawn multiple subtasks and there's always parent-child relationship between them. TaskTree is the main struct that holds configuration for how to spawn/log/report tasks.
Example
use ll::Task;
async fn do_something() {
ll::reporters::term_status::show();
let root_task = Task::create_new("root_task");
root_task.spawn("subtask_1", |task| async move {
task.spawn_sync("subtask_2", |task| {
// do other stuff
Ok(())
})?;
Ok(())
}).await.unwrap();
}
Dependencies
~6–16MB
~218K SLoC