ll/lib.rs
1/*!
2# ll - Logging Library
3
4**ll** is a lightweight logging library. Its main focus is to provide the ability
5to manually instrument portions of code to track and log its execution.
6
7Instrumentation of the code is done by wrapping parts of code into `Tasks`.
8Tasks emit a `start` event when the task is started and `end` event when it's finished.
9
10These events are consumed by `Reporters`. Multiple reporters can be used at the same time
11and they will each receive task events. Different reporters can report/log task events to
12different systems/sources, e.g. print them to STDOUT, write to a database, file or
13third-party system.
14
15Tasks are organized in a task tree. Each task can spawn multiple subtasks and there's always
16parent-child relationship between them.
17TaskTree is the main struct that holds configuration for how to spawn/log/report tasks.
18
19Example
20
21```
22use ll::Task;
23
24async fn do_something() {
25 ll::reporters::term_status::show();
26
27 let root_task = Task::create_new("root_task");
28 root_task.spawn("subtask_1", |task| async move {
29 task.spawn_sync("subtask_2", |task| {
30 // do other stuff
31 Ok(())
32 })?;
33 Ok(())
34 }).await.unwrap();
35}
36```
37
38 */
39#![allow(clippy::new_without_default)]
40
41pub mod data;
42pub mod level;
43pub mod task;
44pub mod task_tree;
45pub mod uniq_id;
46pub mod utils;
47
48pub use task::Task;
49
50pub mod reporters;
51pub use task_tree::add_reporter;
52
53#[cfg(test)]
54mod tests;
55
56pub use data::{Data, DataEntry, DataValue};
57pub use reporters::term_status::TermStatus;
58pub use reporters::text::StdioReporter;
59pub use reporters::text::StringReporter;
60pub use task_tree::ErrorFormatter;
61pub use task_tree::TaskInternal;
62pub use task_tree::TaskTree;