From ae16ddeb2adc33b1ec23abfae29a553c920d8af4 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 23 May 2020 22:28:06 -0400 Subject: wrap log lines when necessary --- src/bin/rbw/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bin/rbw/main.rs b/src/bin/rbw/main.rs index 9160ded..50edd6f 100644 --- a/src/bin/rbw/main.rs +++ b/src/bin/rbw/main.rs @@ -239,7 +239,12 @@ fn main(opt: Opt) { env_logger::Env::default().default_filter_or("info"), ) .format(|buf, record| { - writeln!(buf, "{}: {}", record.level(), record.args()) + if let Some((w, _)) = term_size::dimensions() { + let out = format!("{}: {}", record.level(), record.args()); + writeln!(buf, "{}", textwrap::fill(&out, w - 1)) + } else { + writeln!(buf, "{}: {}", record.level(), record.args()) + } }) .init(); -- cgit v1.2.3-54-g00ecf