Skip to content

Commit

Permalink
feature toggle for dashmap backed tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 10, 2020
1 parent 3da74b0 commit fa688c8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* `Key::adjecency(…)`
* Add `Progress` trait to allow make progress generic
* Add `progress::Discard` and `progress::DoOrDiscard` to make optional progress more convenient, especially when using the `Progress` trait.
* Add `progress-tree` feature to gate the `dashmap` powered tree (enabled by default)

### Breaking

Expand All @@ -28,6 +29,7 @@
* `tree::Progress``Progress`
* Remove `Hash` implementation for all public types except for `tree::Key`
* Move `tui` and `line` renderers into the `render` module
* Rename `log-renderer` feature to `progress-tree-log`

## v7.1.1

Expand Down
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ required-features = [
]

[features]
default = ["log-renderer", "localtime"]
default = ["progress-tree", "progress-tree-log", "localtime"]
progress-tree = ["dashmap", "parking_lot"]
progress-tree-log = ["log"]
unit-bytes = ["bytesize"]
unit-human = ["human_format"]
unit-duration = ["compound_duration"]
Expand All @@ -57,13 +59,12 @@ line-renderer = ["crosstermion/color", "humantime", "unicode-width"]
line-renderer-crossterm = ["crosstermion/crossterm"]
line-renderer-termion = ["crosstermion/termion"]

log-renderer = ["log"]
localtime = ["time"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dashmap = "3.4.3"
parking_lot = "0.11.0"
dashmap = { version = "3.4.3", optional = true, default-features = false }
parking_lot = { version = "0.11.0", optional = true, default-features = false }

# with-logging
log = { version = "0.4.8", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ help: ## Display this help
##@ Testing

clippy: ## Run cargo-clippy
cargo clippy
cargo clippy --all-features

check: ## build features in commmon combination to be sure it all stays together
cargo check --all-features
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ Or run the demo application like so `cd prodash && cargo run --example dashboard

This crate comes with various cargo features to tailor it to your needs.

* **progress-tree** _(default)_
* Provide a `Progress` and `Root` trait implementation for use with the `line-renderer` and `tui-renderer` backed by `dashmap`.
* **progress-tree-log** _(default)_
* If logging in the `log` crate is initialized, a `log` will be used to output all messages provided to
`tree::Item::message(…)` and friends. No actual progress is written.
* May interfere with `tui-renderer` or `line-renderer`
* **local-time** _(default)_
* If set, timestamps in the message pane of the `tui-renderer` will be using the local time, not UTC
* If set, timestamps of the log messages of the `line-renderer` will be using the local time, not UTC
* Has no effect without the `tui-renderer` or `line-renderer` respectively
* **log-renderer** _(default)_
* If logging in the `log` crate is initialized, a `log` will be used to output all messages provided to
`tree::Item::message(…)` and friends.
* May interfere with `tui-renderer` or `line-renderer`
* **line-renderer**
* Provide a minimal line-based progress renderer which can be limited to a subset of the progress hierarchy.
* It's like the tui-renderer, but with far less dependencies and less visual fidelity - all it needs is to move
Expand Down
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ By default, a TUI is provided to visualize all state. Have a look at [the exampl
# Logging
If the feature `log-renderer` is enabled (default), most calls to `progress` will also be logged.
If the feature `progress-tree-log` is enabled (default), most calls to `progress` will also be logged.
That way, even without a terminal user interface, there will be progress messages.
Please note that logging to stdout should not be performed with this feature enabled and a terminal user interface is shown, as this will
seriously interfere with the TUI.
Expand All @@ -33,14 +33,17 @@ Please have a look at the [dashboard demo](https://github.com/Byron/crates-io-cl
Run it with `cargo run --example dashboard` and see what else it can do by checking out `cargo run --example dashboard -- --help`.
*/
#[cfg(feature = "progress-tree")]
pub mod tree;
#[cfg(feature = "progress-tree")]
#[doc(inline)]
pub use tree::{Options as TreeOptions, Root as Tree};

pub mod render;

#[cfg(feature = "log-renderer")]
#[cfg(feature = "progress-tree-log")]
pub use log::info;
#[cfg(feature = "log-renderer")]
#[cfg(feature = "progress-tree-log")]
pub use log::warn;

#[cfg(any(feature = "humantime", feature = "time"))]
Expand All @@ -59,7 +62,7 @@ pub use traits::{Progress, Root};
mod throughput;
pub use crate::throughput::Throughput;

#[cfg(not(feature = "log-renderer"))]
#[cfg(not(feature = "progress-tree-log"))]
mod log {
/// Stub
#[macro_export(local_inner_macros)]
Expand Down
2 changes: 1 addition & 1 deletion src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Message {
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub(crate) struct MessageRingBuffer {
pub struct MessageRingBuffer {
pub(crate) buf: Vec<Message>,
cursor: usize,
total: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/tree/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl Item {
{
let name = self.tree.get(&self.key).map(|v| v.name.to_owned()).unwrap_or_default();

#[cfg(feature = "log-renderer")]
#[cfg(feature = "progress-tree-log")]
match level {
MessageLevel::Failure => crate::warn!("{} → {}", name, message),
MessageLevel::Info | MessageLevel::Success => crate::info!("{} → {}", name, message),
Expand Down

0 comments on commit fa688c8

Please sign in to comment.