ts 0.0.0

Prepend timestamps to lines of text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use chrono::Local;
use std::io::{self, BufRead, BufReader};

fn main() -> io::Result<()> {
    let stdin = io::stdin();
    let reader = BufReader::new(stdin);

    for line in reader.lines() {
        let line = line?;
        let timestamp = Local::now().format("[%Y-%m-%d %H:%M:%S]");
        println!("{} {}", timestamp, line);
    }

    Ok(())
}