blob: 57f12be9cfe0e27e3c98095c9f0170f5e2c522d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use shiplift::{tty::StreamType, Docker, LogsOptions};
use std::env;
use tokio::prelude::{Future, Stream};
fn main() {
let docker = Docker::new();
let id = env::args()
.nth(1)
.expect("You need to specify a container id");
let fut = docker
.containers()
.get(&id)
.logs(&LogsOptions::builder().stdout(true).stderr(true).build())
.for_each(|chunk| {
match chunk.stream_type {
StreamType::StdOut => println!("Stdout: {}", chunk.as_string_lossy()),
StreamType::StdErr => eprintln!("Stderr: {}", chunk.as_string_lossy()),
StreamType::StdIn => unreachable!(),
}
Ok(())
})
.map_err(|e| eprintln!("Error: {}", e));
tokio::run(fut);
}
|