Skip to content

Commit

Permalink
Basis for overdraw of log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 9, 2020
1 parent 3484fed commit 7a4aecf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ check: ## build features in commmon combination to be sure it all stays together
cargo check --features tui-renderer,tui-renderer-termion
cargo check --features line-renderer,line-renderer-termion
cargo check --features line-renderer,line-renderer-crossterm
cargo check --features line-renderer,line-renderer-termion,tui-renderer,tui-renderer-termion --example dashboard-termion
cargo check --features line-renderer,line-renderer-crossterm,tui-renderer,tui-renderer-crossterm --example dashboard
cargo check
$(MAKE) -C crosstermion check

Expand Down
23 changes: 16 additions & 7 deletions src/line/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ fn messages(out: &mut impl io::Write, state: &mut State, colored: bool, timestam
Failure => Color::Red,
}
}
for tree::Message {
time,
level,
origin,
message,
} in &state.messages
for (
tree::Message {
time,
level,
origin,
message,
},
last_drawn_line_length,
) in state
.messages
.iter()
.zip(state.blocks_per_line.iter().chain(std::iter::repeat(&0)))
{
let message_block_len = origin.width();
state.max_message_origin_size = state.max_message_origin_size.max(message_block_len);
let color = to_color(*level);
writeln!(
out,
" {}{} {}",
" {}{} {}{:>overdraw_size$}",
if timestamp {
format!(
"{} ",
Expand All @@ -63,6 +69,8 @@ fn messages(out: &mut impl io::Write, state: &mut State, colored: bool, timestam
fill_size = state.max_message_origin_size - message_block_len,
)),
brush.style(color.bold()).paint(message),
"",
overdraw_size = 0,
)?;
}
Ok(())
Expand Down Expand Up @@ -138,4 +146,5 @@ fn format_progress<'a>(key: &tree::Key, progress: &'a tree::Value, ticks: usize,
buf.push(Style::new().paint(format!("{:>level$}", "", level = key.level() as usize)));
buf.push(Color::Yellow.paint(format!("{}", ticks)));
buf.push(Color::Green.on(Color::Red).paint(&progress.name));
buf.push(Style::new().paint("long text long text long text long text long text long text long text long text long text long text long text "));
}

0 comments on commit 7a4aecf

Please sign in to comment.