@@ -72,7 +72,7 @@ use uuid::Uuid;
7272
7373pub use crate :: args:: { Command , ProjectArgs , RunArgs , ShuttleArgs } ;
7474use crate :: args:: {
75- DeployArgs , DeploymentCommand , InitArgs , LoginArgs , LogoutArgs , ProjectCommand ,
75+ DeployArgs , DeploymentCommand , InitArgs , LoginArgs , LogoutArgs , LogsArgs , ProjectCommand ,
7676 ProjectStartArgs , ResourceCommand , TemplateLocation ,
7777} ;
7878use crate :: client:: Client ;
@@ -222,12 +222,7 @@ impl Shuttle {
222222 Command :: Run ( run_args) => self . local_run ( run_args) . await ,
223223 Command :: Deploy ( deploy_args) => self . deploy ( deploy_args) . await ,
224224 Command :: Status => self . status ( ) . await ,
225- Command :: Logs {
226- id,
227- latest,
228- follow,
229- raw,
230- } => self . logs ( id, latest, follow, raw) . await ,
225+ Command :: Logs ( logs_args) => self . logs ( logs_args) . await ,
231226 Command :: Deployment ( DeploymentCommand :: List { page, limit, raw } ) => {
232227 self . deployments_list ( page, limit, raw) . await
233228 }
@@ -843,20 +838,14 @@ impl Shuttle {
843838 Ok ( CommandOutcome :: Ok )
844839 }
845840
846- async fn logs (
847- & self ,
848- id : Option < Uuid > ,
849- latest : bool ,
850- follow : bool ,
851- raw : bool ,
852- ) -> Result < CommandOutcome > {
841+ async fn logs ( & self , args : LogsArgs ) -> Result < CommandOutcome > {
853842 let client = self . client . as_ref ( ) . unwrap ( ) ;
854- let id = if let Some ( id) = id {
843+ let id = if let Some ( id) = args . id {
855844 id
856845 } else {
857846 let proj_name = self . ctx . project_name ( ) ;
858847
859- if latest {
848+ if args . latest {
860849 // Find latest deployment (not always an active one)
861850 let deployments = client
862851 . get_deployments ( proj_name, 0 , 1 )
@@ -883,7 +872,7 @@ impl Shuttle {
883872 }
884873 } ;
885874
886- if follow {
875+ if args . follow {
887876 let mut stream = client
888877 . get_logs_ws ( self . ctx . project_name ( ) , & id)
889878 . await
@@ -895,10 +884,10 @@ impl Shuttle {
895884 if let tokio_tungstenite:: tungstenite:: Message :: Text ( line) = msg {
896885 match serde_json:: from_str :: < shuttle_common:: LogItem > ( & line) {
897886 Ok ( log) => {
898- if raw {
899- println ! ( "{}" , log. get_raw_line( ) ) ;
887+ if args . raw {
888+ println ! ( "{}" , log. get_raw_line( ) )
900889 } else {
901- println ! ( "{log}" ) ;
890+ println ! ( "{log}" )
902891 }
903892 }
904893 Err ( err) => {
@@ -924,10 +913,10 @@ impl Shuttle {
924913 } ) ?;
925914
926915 for log in logs. into_iter ( ) {
927- if raw {
928- println ! ( "{}" , log. get_raw_line( ) ) ;
916+ if args . raw {
917+ println ! ( "{}" , log. get_raw_line( ) )
929918 } else {
930- println ! ( "{log}" ) ;
919+ println ! ( "{log}" )
931920 }
932921 }
933922 }
@@ -1117,14 +1106,20 @@ impl Shuttle {
11171106 . context ( "child process did not have a handle to stdout" ) ?;
11181107 let mut reader = BufReader :: new ( child_stdout) . lines ( ) ;
11191108 let service_name_clone = service_name. clone ( ) ;
1109+ let raw = run_args. raw ;
11201110 tokio:: spawn ( async move {
11211111 while let Some ( line) = reader. next_line ( ) . await . unwrap ( ) {
11221112 let log_item = LogItem :: new (
11231113 deployment_id,
11241114 shuttle_common:: log:: Backend :: Runtime ( service_name_clone. clone ( ) ) ,
11251115 line,
11261116 ) ;
1127- println ! ( "{log_item}" ) ;
1117+
1118+ if raw {
1119+ println ! ( "{}" , log_item. get_raw_line( ) )
1120+ } else {
1121+ println ! ( "{log_item}" )
1122+ }
11281123 }
11291124 } ) ;
11301125
@@ -1717,7 +1712,11 @@ impl Shuttle {
17171712 }
17181713 } ;
17191714
1720- println ! ( "{log_item}" ) ;
1715+ if args. raw {
1716+ println ! ( "{}" , log_item. get_raw_line( ) )
1717+ } else {
1718+ println ! ( "{log_item}" )
1719+ }
17211720
17221721 // Detect versions of deployer and runtime, and print warnings of outdated.
17231722 if !deployer_version_checked
0 commit comments