Skip to content

Commit 01dbd3a

Browse files
authored
Revert "chore: remove logs --all-deployments (#2040)" + hide it instead (#2047)
* Revert "chore: remove logs --all-deployments (#2040)" This reverts commit b2492e8. * hide logs --all-deployments
1 parent a813539 commit 01dbd3a

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

api-client/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ impl ShuttleApiClient {
262262

263263
self.get_json(path).await
264264
}
265+
pub async fn get_project_logs(&self, project: &str) -> Result<LogsResponse> {
266+
let path = format!("/projects/{project}/logs");
267+
268+
self.get_json(path).await
269+
}
265270

266271
pub async fn get_deployments(
267272
&self,

cargo-shuttle/src/args.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ pub struct LogsArgs {
487487
/// Deployment ID to get logs for. Defaults to the current deployment
488488
pub id: Option<String>,
489489
#[arg(short, long)]
490-
/// View logs from the most recent deployment (which is not always the latest running one)
490+
/// View logs from the most recent deployment (which is not always the running one)
491491
pub latest: bool,
492492
#[arg(short, long, hide = true)]
493493
/// Follow log output
@@ -504,6 +504,9 @@ pub struct LogsArgs {
504504
/// View all log lines
505505
#[arg(long, group = "output_mode", hide = true)]
506506
pub all: bool,
507+
/// Get logs from all deployments instead of one deployment
508+
#[arg(long, hide = true)]
509+
pub all_deployments: bool,
507510
}
508511

509512
/// Helper function to parse and return the absolute path

cargo-shuttle/src/lib.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -937,28 +937,30 @@ impl Shuttle {
937937
}
938938
let client = self.client.as_ref().unwrap();
939939
let pid = self.ctx.project_id();
940-
941-
let id = if args.latest {
942-
// Find latest deployment (not always an active one)
943-
let deployments = client.get_deployments(pid, 1, 1).await?.deployments;
944-
let Some(most_recent) = deployments.into_iter().next() else {
945-
println!("No deployments found");
946-
return Ok(());
947-
};
948-
eprintln!("Getting logs from: {}", most_recent.id);
949-
most_recent.id
950-
} else if let Some(id) = args.id {
951-
id
940+
let logs = if args.all_deployments {
941+
client.get_project_logs(pid).await?.logs
952942
} else {
953-
let Some(current) = client.get_current_deployment(pid).await? else {
954-
println!("No deployments found");
955-
return Ok(());
943+
let id = if args.latest {
944+
// Find latest deployment (not always an active one)
945+
let deployments = client.get_deployments(pid, 1, 1).await?.deployments;
946+
let Some(most_recent) = deployments.into_iter().next() else {
947+
println!("No deployments found");
948+
return Ok(());
949+
};
950+
eprintln!("Getting logs from: {}", most_recent.id);
951+
most_recent.id
952+
} else if let Some(id) = args.id {
953+
id
954+
} else {
955+
let Some(current) = client.get_current_deployment(pid).await? else {
956+
println!("No deployments found");
957+
return Ok(());
958+
};
959+
eprintln!("Getting logs from: {}", current.id);
960+
current.id
956961
};
957-
eprintln!("Getting logs from: {}", current.id);
958-
current.id
962+
client.get_deployment_logs(pid, &id).await?.logs
959963
};
960-
let logs = client.get_deployment_logs(pid, &id).await?.logs;
961-
962964
for log in logs {
963965
if args.raw {
964966
println!("{}", log.line);

0 commit comments

Comments
 (0)