43 releases

Uses new Rust 2021

0.8.1 Oct 12, 2022
0.8.0 Jun 12, 2022
0.7.1 Feb 7, 2022
0.6.5 Nov 16, 2021
0.1.13 May 25, 2018

#17 in Debugging

Download history 471/week @ 2022-10-05 309/week @ 2022-10-12 275/week @ 2022-10-19 560/week @ 2022-10-26 731/week @ 2022-11-02 624/week @ 2022-11-09 412/week @ 2022-11-16 398/week @ 2022-11-23 502/week @ 2022-11-30 432/week @ 2022-12-07 618/week @ 2022-12-14 439/week @ 2022-12-21 290/week @ 2022-12-28 287/week @ 2023-01-04 632/week @ 2023-01-11 263/week @ 2023-01-18

1,515 downloads per month
Used in fewer than 15 crates

MIT license

1.5K SLoC

Logger with smart widget for the tui crate

dependency status Build examples

Demo of the widget





  • Logger implementation for the log crate
  • Logger enable/disable detection via hash table (avoid string compare)
  • Hot logger code only copies enabled log messages with timestamp into a circular buffer
  • Widgets/move_message() retrieve captured log messages from hot circular buffer
  • Lost message detection due to circular buffer
  • Log filtering performed on log record target
  • Simple Widgets to view logs and configure debuglevel per target
  • Logging of enabled logs to file
  • Scrollback in log history
  • Title of target and log pane can be configured
  • slog support, providing a Drain to integrate into your slog infrastructure
  • Allow configuration of target dependent loglevel specifically for file logging
  • Avoid duplicating of target, module and filename in every log record
  • Simultaneous modification of all targets' display/hot logging loglevel by key command

Smart Widget

Smart widget consists of two widgets. Left is the target selector widget and on the right side the logging messages view scrolling up. The target selector widget can be hidden/shown during runtime via key command. The key command to be provided to the TuiLoggerWidget via transition() function.

The target selector widget looks like this:


It controls:

  • Capturing of log messages by the logger
  • Selection of levels for display in the logging message view

The two columns have the following meaning:

  • Code EWIDT: E stands for Error, W for Warn, Info, Debug and Trace.
    • Inverted characters (EWIDT) are enabled log levels in the view
    • Normal characters show enabled capturing of a log level per target
    • If any of EWIDT are not shown, then the respective log level is not captured
  • Target of the log events can be defined in the log e.g. warn!(target: "demo", "Log message");

Smart Widget Key Commands

|  KEY     | ACTION
| h        | Toggles target selector widget hidden/visible
| f        | Toggle focus on the selected target only
| UP       | Select previous target in target selector widget
| DOWN     | Select next target in target selector widget
| LEFT     | Reduce SHOWN (!) log messages by one level
| RIGHT    | Increase SHOWN (!) log messages by one level
| -        | Reduce CAPTURED (!) log messages by one level
| +        | Increase CAPTURED (!) log messages by one level
| PAGEUP   | Enter Page Mode and scroll approx. half page up in log history.
| PAGEDOWN | Only in page mode: scroll 10 events down in log history.
| ESCAPE   | Exit page mode and go back to scrolling mode
| SPACE    | Toggles hiding of targets, which have logfilter set to off

The mapping of key to action has to be done in the application. The respective TuiWidgetEvent has to be provided to TuiWidgetState::transition().

Remark to the page mode: The timestamp of the event at event history's bottom line is used as reference. This means, changing the filters in the EWIDT/focus from the target selector window should work as expected without jumps in the history. The page next/forward advances as per visibility of the events.

Basic usage to initialize logger-system:

extern crate log;
//use tui_logger;

fn main() {
    // Early initialization of the logger

    // Set max_log_level to Trace

    // Set default level for unknown targets to Trace

    // code....

For use of the widget please check examples/demo.rs

slog support

tui-logger provides a TuiSlogDrain which implements slog::Drain and will route all records it receives to the tui-logger widget

Applications using tui-logger



~110K SLoC