pub fn print_log(task_id: usize, state: &State) {
    let task = match state.tasks.get(&task_id) {
        Some(task) => task,
        None => return,
    };

    // We only show logs of finished tasks
    if !vec![TaskStatus::Done, TaskStatus::Failed].contains(&task.status) {
        return;
    }

    let exit_status = match task.exit_code {
        Some(code) => match code {
            0 => style(format!("with exit code {}", code)).with(Color::Green),
            _ => style(format!("with exit code {}", code)).with(Color::Red),
        },
        None => style("failed to Spawn".to_string()).with(Color::Red),
    };

    // Print task id and exit code
    println!("\n");
    print!(
        "{}",
        style(format!("Task {} ", task.id)).attribute(Attribute::Bold)
    );
    println!("{}", exit_status);

    // Print command and path
    println!("Command: {}", task.command);
    println!("Path: {}", task.path);
    if let Some(start) = task.start {
        println!("Start: {}", start.to_rfc2822());
    }
    if let Some(end) = task.end {
        println!("End: {}", end.to_rfc2822());
    }

    if let Some(stdout) = &task.stdout {
        if !stdout.is_empty() {
            println!(
                "{}",
                style("Std_out: ")
                    .with(Color::Green)
                    .attribute(Attribute::Bold)
            );
            println!("{}", stdout);
        }
    }

    if let Some(stderr) = &task.stderr {
        if !stderr.is_empty() {
            println!(
                "{}",
                style("Std_err: ")
                    .with(Color::Red)
                    .attribute(Attribute::Bold)
            );
            println!("{}", stderr);
        }
    }
}
/// Print the log of a single task.
Print the log of a single task.
Print the log of a single task .
pub fn print_log(task_id: usize, state: &State) {
    let task = match state.tasks.get(&task_id) {
        Some(task) => task,
        None => return,
    };
    // We only show logs of finished tasks
    if !vec![TaskStatus::Done, TaskStatus::Failed].contains(&task.status) {
        return;
    }
    let exit_status = match task.exit_code {
        Some(code) => match code {
            0 => style(format!("with exit code {}", code)).with(Color::Green),
            _ => style(format!("with exit code {}", code)).with(Color::Red),
        },
        None => style("failed to Spawn".to_string()).with(Color::Red),
    };
    // Print task id and exit code
    println!("\n");
    print!(
        "{}",
        style(format!("Task {} ", task.id)).attribute(Attribute::Bold)
    );
    println!("{}", exit_status);
    // Print command and path
    println!("Command: {}", task.command);
    println!("Path: {}", task.path);
    if let Some(start) = task.start {
        println!("Start: {}", start.to_rfc2822());
    }
    if let Some(end) = task.end {
        println!("End: {}", end.to_rfc2822());
    }
    if let Some(stdout) = &task.stdout {
        if !stdout.is_empty() {
            println!(
                "{}",
                style("Std_out: ")
                    .with(Color::Green)
                    .attribute(Attribute::Bold)
            );
            println!("{}", stdout);
        }
    }
    if let Some(stderr) = &task.stderr {
        if !stderr.is_empty() {
            println!(
                "{}",
                style("Std_err: ")
                    .with(Color::Red)
                    .attribute(Attribute::Bold)
            );
            println!("{}", stderr);
        }
    }
}
pub fn print_log ( task_id : usize , state : & State ) { let task = match state . tasks . get ( & task_id ) { Some ( task ) => task , None => return , } ; // We only show logs of finished tasks if ! vec ! [ TaskStatus Done TaskStatus Failed ] . contains ( & task . status ) { return ; } let exit_status = match task . exit_code { Some ( code ) => match code { 0 => style ( format ! ( " " code ) ) . with ( Color :: Green ) , _ => style ( format ! ( " " code ) ) . with ( Color :: Red ) , } , None => style ( " " . to_string ( ) ) . with ( Color :: Red ) , } ; // Print task id and exit code println ! ( " \n " ) ; print ! ( " " style ( format ( " " task id ) ) attribute ( Attribute Bold ) ) ; println ! ( " " exit_status ) ; // Print command and path println ! ( " " task command ) ; println ! ( " " task path ) ; if let Some ( start ) = task . start { println ! ( " " start to_rfc2822 ( ) ) ; } if let Some ( end ) = task . end { println ! ( " " end to_rfc2822 ( ) ) ; } if let Some ( stdout ) = & task . stdout { if ! stdout . is_empty ( ) { println ! ( " " style ( " " ) with ( Color Green ) attribute ( Attribute Bold ) ) ; println ! ( " " stdout ) ; } } if let Some ( stderr ) = & task . stderr { if ! stderr . is_empty ( ) { println ! ( " " style ( " " ) with ( Color Red ) attribute ( Attribute Bold ) ) ; println ! ( " " stderr ) ; } } }
Print the log of a single task.
Print the log of a single task .
task_id
usize
state
&State
task_id
usize
state
&State