log-update

Crates.iolog-update
lib.rslog-update
version0.1.0
sourcesrc
created_at2016-11-01 21:21:30.321665
updated_at2016-11-01 21:21:30.321665
descriptionLog by overwriting the previous output in the terminal
homepagehttps://github.com/LinusU/rust-log-update
repositoryhttps://github.com/LinusU/rust-log-update
max_upload_size
id7105
size5,077
Linus Unnebäck (LinusU)

documentation

https://docs.rs/log-update

README

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.

Commit count: 1

cargo fmt