-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a way to access logs through the CLI
- Loading branch information
1 parent
9042354
commit 186a04c
Showing
9 changed files
with
802 additions
and
53 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use dora_core::topics::{ControlRequest, ControlRequestReply}; | ||
use eyre::{bail, Context, Result}; | ||
use uuid::Uuid; | ||
|
||
use crate::control_connection; | ||
use bat::{Input, PrettyPrinter}; | ||
|
||
pub fn logs(uuid: Option<Uuid>, name: Option<String>, node: String) -> Result<()> { | ||
let mut control_session = None; | ||
let connection = control_connection(&mut control_session)?; | ||
let logs = { | ||
let reply_raw = connection | ||
.request(&serde_json::to_vec(&ControlRequest::Logs { | ||
uuid, | ||
name, | ||
node: node.clone(), | ||
})?) | ||
.wrap_err("failed to send DaemonConnected message")?; | ||
|
||
let reply = serde_json::from_slice(&reply_raw).wrap_err("failed to parse reply")?; | ||
match reply { | ||
ControlRequestReply::Logs { logs } => logs, | ||
other => bail!("unexpected reply to daemon connection check: {other:?}"), | ||
} | ||
}; | ||
|
||
PrettyPrinter::new() | ||
.header(true) | ||
.grid(true) | ||
.line_numbers(true) | ||
.paging_mode(bat::PagingMode::Always) | ||
.inputs(vec![Input::from_bytes(&logs) | ||
.name("Logs") // TODO: Make a better name | ||
.title(format!("Logs from {node}.").as_str())]) | ||
.print() | ||
.unwrap(); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters