#output #refresh #log #animation #overwrite

log-update

Log by overwriting the previous output in the terminal

1 unstable release

Uses old Rust 2015

0.1.0 Nov 1, 2016

#10 in #overwrite

Download history 15/week @ 2024-07-22 17/week @ 2024-07-29 17/week @ 2024-08-05 19/week @ 2024-08-12 13/week @ 2024-08-19 11/week @ 2024-08-26 15/week @ 2024-09-02 23/week @ 2024-09-09 23/week @ 2024-09-16 44/week @ 2024-09-23 25/week @ 2024-09-30 1/week @ 2024-10-07 20/week @ 2024-10-14 39/week @ 2024-10-21 18/week @ 2024-10-28 16/week @ 2024-11-04

93 downloads per month
Used in 3 crates

MIT license

5KB
76 lines

Log Update

Log by overwriting the previous output in the terminal.

Useful for rendering progress bars, animations, etc.

Usage

This example will count down from 3 and then display Lift off! 🚀.

extern crate log_update;

use log_update::LogUpdate;

use std::io::stdout;
use std::thread::sleep;
use std::time::Duration;

fn main() {
    // Construct the log updater
    let mut log_update = LogUpdate::new(stdout()).unwrap();

    for i in [3, 2, 1].iter() {
        // Update log to show message
        log_update.render(&format!("Lift off in {}...", i)).unwrap();

        // Sleep for one second
        sleep(Duration::from_secs(1));
    }

    // Print final message
    log_update.render("Lift off! 🚀").unwrap();
}

API

See documentation

Inspiration

Heavily inspired by @sindresorhus’ excellent log-update.

Dependencies

~10KB