22// Copyright 2025 Keylime Authors
33use crate :: struct_filler:: StructureFiller ;
44use clap:: Parser ;
5- use std:: error:: Error ;
6- use std:: fs:: File ;
7- use std:: io:: Read ;
8- use std:: time:: Duration ;
5+ use log:: { debug, error, info} ;
6+ use std:: { error:: Error , fs:: File , io:: Read , time:: Duration } ;
97mod struct_filler;
108
119const DEFAULT_TIMEOUT_MILLIS : & str = "5000" ;
@@ -95,7 +93,7 @@ async fn send_attestation_request(
9593 let filler = get_attestation_filler_request ( args) ;
9694 let request = filler. get_attestation_request ( ) ;
9795 let serialized = serde_json:: to_string ( & request) . unwrap ( ) ;
98- println ! ( "Serialized Request: {}" , serialized) ;
96+ info ! ( "Serialized Request: {}" , serialized) ;
9997 let reqb = get_request_builder_from_method ( args) ?;
10098
10199 let response = reqb
@@ -105,11 +103,11 @@ async fn send_attestation_request(
105103 . timeout ( Duration :: from_millis ( args. timeout ) )
106104 . send ( )
107105 . await ?;
108- println ! ( "Response code:{}" , response. status( ) ) ;
109- println ! ( "Response headers: {:?}" , response. headers( ) ) ;
106+ info ! ( "Response code:{}" , response. status( ) ) ;
107+ info ! ( "Response headers: {:?}" , response. headers( ) ) ;
110108 let response_body = response. text ( ) . await ?;
111109 if !response_body. is_empty ( ) {
112- println ! ( "Response body: {}" , response_body) ;
110+ info ! ( "Response body: {}" , response_body) ;
113111 }
114112 Ok ( response_body)
115113}
@@ -149,21 +147,22 @@ struct Args {
149147
150148async fn run ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
151149 let args = Args :: parse ( ) ;
152- println ! ( "API version: {}" , get_api_version( & args) ) ;
153- println ! ( "Verifier URL: {}" , args. verifier_url) ;
154- println ! ( "Timeout: {}" , args. timeout) ;
155- println ! ( "Certificate file: {}" , args. certificate) ;
156- println ! ( "Insecure: {}" , args. insecure. unwrap_or( false ) ) ;
150+ info ! ( "API version: {}" , get_api_version( & args) ) ;
151+ info ! ( "Verifier URL: {}" , args. verifier_url) ;
152+ debug ! ( "Timeout: {}" , args. timeout) ;
153+ debug ! ( "Certificate file: {}" , args. certificate) ;
154+ debug ! ( "Insecure: {}" , args. insecure. unwrap_or( false ) ) ;
157155 let res = send_attestation_request ( & args) . await ;
158156 match res {
159- Ok ( _) => println ! ( "Request sent successfully" ) ,
160- Err ( e) => eprintln ! ( "Error: {}" , e) ,
157+ Ok ( _) => info ! ( "Request sent successfully" ) ,
158+ Err ( e) => error ! ( "Error: {}" , e) ,
161159 }
162160 Ok ( ( ) )
163161}
164162
165163#[ actix_web:: main]
166164async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
165+ pretty_env_logger:: init ( ) ;
167166 run ( ) . await
168167}
169168
0 commit comments