@@ -78,7 +78,7 @@ pub async fn disconnect(
7878 info ! ( "Disconnected from location with id: {location_id}" ) ;
7979 Ok ( ( ) )
8080 } else {
81- error ! ( "Connection for location with id: {location_id} not found" ) ;
81+ error ! ( "Error while disconnecting from location with id: {location_id} not found" ) ;
8282 Err ( Error :: NotFound )
8383 }
8484}
@@ -130,7 +130,7 @@ pub async fn save_device_config(
130130 app_state : State < ' _ , AppState > ,
131131 handle : AppHandle ,
132132) -> Result < SaveDeviceConfigResponse , Error > {
133- debug ! ( "Received device configuration: {response:#?}" ) ;
133+ debug ! ( "Received device configuration: {response:#?}. " ) ;
134134
135135 let mut transaction = app_state. get_pool ( ) . begin ( ) . await ?;
136136 let instance_info = response
@@ -168,6 +168,7 @@ pub async fn save_device_config(
168168 locations,
169169 instance,
170170 } ;
171+ info ! ( "Device configuration saved." ) ;
171172 Ok ( res)
172173}
173174
@@ -309,6 +310,7 @@ pub async fn update_instance(
309310 let mut transaction = pool. begin ( ) . await ?;
310311
311312 // update instance
313+ debug ! ( "Updating instance {instance_id}." ) ;
312314 let instance_info = response
313315 . instance
314316 . expect ( "Missing instance info in device config response" ) ;
@@ -319,6 +321,7 @@ pub async fn update_instance(
319321 instance. save ( & mut * transaction) . await ?;
320322
321323 // process locations received in response
324+ debug ! ( "Updating locations for instance {instance_id}." ) ;
322325 for location in response. configs {
323326 // parse device config
324327 let mut new_location = device_config_to_location ( location, instance_id) ;
@@ -330,6 +333,10 @@ pub async fn update_instance(
330333 {
331334 // remove from list of existing locations
332335 let mut current_location = current_locations. remove ( position) ;
336+ debug ! (
337+ "Updating existing location {} for instance {instance_id}." ,
338+ current_location. name
339+ ) ;
333340 // update existing location
334341 current_location. name = new_location. name ;
335342 current_location. address = new_location. address ;
@@ -339,17 +346,26 @@ pub async fn update_instance(
339346 current_location. mfa_enabled = new_location. mfa_enabled ;
340347 current_location. keepalive_interval = new_location. keepalive_interval ;
341348 current_location. save ( & mut * transaction) . await ?;
349+ info ! (
350+ "Location {} updated for instance {instance_id}." ,
351+ current_location. name
352+ ) ;
342353 } else {
343354 // create new location
355+ debug ! ( "Creating new location for instance {instance_id}." ) ;
344356 new_location. save ( & mut * transaction) . await ?;
357+ info ! ( "New location created for instance {instance_id}." ) ;
345358 }
346359 }
360+ info ! ( "Locations updated for instance {instance_id}." ) ;
347361
348362 // remove locations which were present in current locations
349363 // but no longer found in core response
364+ debug ! ( "Removing locations for instance {instance_id}." ) ;
350365 for removed_location in current_locations {
351366 removed_location. delete ( & mut * transaction) . await ?;
352367 }
368+ info ! ( "Locations removed for instance {instance_id}." ) ;
353369
354370 transaction. commit ( ) . await ?;
355371
@@ -456,7 +472,7 @@ pub async fn all_connections(
456472 . collect ( )
457473 }
458474 } ;
459- debug ! ( "Connections received, returning." ) ;
475+ info ! ( "Connections retrieved({})" , connections . len ( ) ) ;
460476 trace ! ( "Connections found:\n {:#?}" , connections) ;
461477 Ok ( connections)
462478}
@@ -469,7 +485,7 @@ pub async fn all_tunnel_connections(
469485 debug ! ( "Retrieving connections for location {location_id}" ) ;
470486 let connections =
471487 TunnelConnectionInfo :: all_by_tunnel_id ( & app_state. get_pool ( ) , location_id) . await ?;
472- debug ! ( "Connections received, returning." ) ;
488+ info ! ( "Tunnel connections retrieved({})" , connections . len ( ) ) ;
473489 trace ! ( "Connections found:\n {:#?}" , connections) ;
474490 Ok ( connections)
475491}
@@ -487,8 +503,8 @@ pub async fn active_connection(
487503 if connection. is_some ( ) {
488504 debug ! ( "Active connection found" ) ;
489505 }
490- trace ! ( "Connection:\n {:#?}" , connection) ;
491- debug ! ( "Connection returned " ) ;
506+ trace ! ( "Connection retrieved :\n {:#?}" , connection) ;
507+ info ! ( "Connection retrieved " ) ;
492508 Ok ( connection)
493509}
494510
@@ -503,18 +519,18 @@ pub async fn last_connection(
503519 if let Some ( connection) =
504520 Connection :: latest_by_location_id ( & app_state. get_pool ( ) , location_id) . await ?
505521 {
506- trace ! ( "Connection found" ) ;
522+ info ! ( "Found last connection at {}" , connection . end ) ;
507523 Ok ( Some ( connection. into ( ) ) )
508524 } else {
509525 Ok ( None )
510526 }
511527 } else if let Some ( connection) =
512528 TunnelConnection :: latest_by_tunnel_id ( & app_state. get_pool ( ) , location_id) . await ?
513529 {
514- trace ! ( "Connection found" ) ;
530+ info ! ( "Found last connection at {}" , connection . end ) ;
515531 Ok ( Some ( connection. into ( ) ) )
516532 } else {
517- trace ! ( "No last connection found" ) ;
533+ info ! ( "No last connection found" ) ;
518534 Ok ( None )
519535 }
520536}
@@ -536,7 +552,7 @@ pub async fn update_location_routing(
536552 {
537553 location. route_all_traffic = route_all_traffic;
538554 location. save ( & app_state. get_pool ( ) ) . await ?;
539- debug ! ( "Location routing updated for location {location_id}" ) ;
555+ info ! ( "Location routing updated for location {location_id}" ) ;
540556 handle. emit_all (
541557 "location-update" ,
542558 Payload {
@@ -556,7 +572,7 @@ pub async fn update_location_routing(
556572 {
557573 tunnel. route_all_traffic = route_all_traffic;
558574 tunnel. save ( & app_state. get_pool ( ) ) . await ?;
559- debug ! ( "Tunnel routing updated for tunnel {location_id}" ) ;
575+ info ! ( "Tunnel routing updated for tunnel {location_id}" ) ;
560576 handle. emit_all (
561577 "location-update" ,
562578 Payload {
@@ -577,6 +593,7 @@ pub async fn get_settings(handle: AppHandle) -> Result<Settings, Error> {
577593 debug ! ( "Retrieving settings" ) ;
578594 let app_state = handle. state :: < AppState > ( ) ;
579595 let settings = Settings :: get ( & app_state. get_pool ( ) ) . await ?;
596+ info ! ( "Settings retrieved" ) ;
580597 Ok ( settings)
581598}
582599
@@ -595,7 +612,7 @@ pub async fn update_settings(data: SettingsPatch, handle: AppHandle) -> Result<S
595612 Ok ( _) => { }
596613 Err ( e) => {
597614 error ! (
598- "During settings update, tray configuration update failed . err : {}" ,
615+ "Tray configuration update failed during settings update . err : {}" ,
599616 e. to_string( )
600617 ) ;
601618 }
@@ -632,7 +649,7 @@ pub async fn delete_instance(instance_id: i64, handle: AppHandle) -> Result<(),
632649 error ! ( "{msg}" ) ;
633650 Error :: InternalError ( msg)
634651 } ) ?;
635- debug ! ( "Connection closed and interface removed" ) ;
652+ info ! ( "Connection closed and interface removed" ) ;
636653 }
637654 }
638655 }
@@ -648,10 +665,12 @@ pub async fn delete_instance(instance_id: i64, handle: AppHandle) -> Result<(),
648665#[ tauri:: command( async ) ]
649666pub async fn parse_tunnel_config ( config : String ) -> Result < Tunnel , Error > {
650667 debug ! ( "Parsing config file" ) ;
651- parse_wireguard_config ( & config) . map_err ( |error| {
668+ let tunnel_config = parse_wireguard_config ( & config) . map_err ( |error| {
652669 error ! ( "{error}" ) ;
653670 Error :: ConfigParseError ( error. to_string ( ) )
654- } )
671+ } ) ?;
672+ info ! ( "Config file parsed" ) ;
673+ Ok ( tunnel_config)
655674}
656675#[ tauri:: command( async ) ]
657676pub async fn save_tunnel ( mut tunnel : Tunnel , handle : AppHandle ) -> Result < ( ) , Error > {
@@ -700,6 +719,8 @@ pub async fn all_tunnels(app_state: State<'_, AppState>) -> Result<Vec<TunnelInf
700719 connection_type : ConnectionType :: Tunnel ,
701720 } )
702721 }
722+
723+ info ! ( "Tunnels retrieved({})" , tunnel_info. len( ) ) ;
703724 Ok ( tunnel_info)
704725}
705726#[ tauri:: command( async ) ]
@@ -710,7 +731,7 @@ pub async fn tunnel_details(
710731 debug ! ( "Retrieving Tunnel with ID {tunnel_id}." ) ;
711732
712733 if let Some ( tunnel) = Tunnel :: find_by_id ( & app_state. get_pool ( ) , tunnel_id) . await ? {
713- debug ! ( "Found tunnel {tunnel_id}" ) ;
734+ info ! ( "Found tunnel {tunnel_id}" ) ;
714735 Ok ( tunnel)
715736 } else {
716737 error ! ( "Tunnel with ID: {tunnel_id}, not found" ) ;
@@ -745,7 +766,7 @@ pub async fn delete_tunnel(tunnel_id: i64, handle: AppHandle) -> Result<(), Erro
745766 error ! ( "{msg}" ) ;
746767 Error :: InternalError ( msg)
747768 } ) ?;
748- debug ! ( "Connection closed and interface removed" ) ;
769+ info ! ( "Connection closed and interface removed" ) ;
749770 }
750771 tunnel. delete ( pool) . await ?;
751772 } else {
@@ -798,10 +819,13 @@ pub async fn get_latest_app_version(handle: AppHandle) -> Result<AppVersionInfo,
798819 let response_json: Result < AppVersionInfo , reqwest:: Error > =
799820 response. json :: < AppVersionInfo > ( ) . await ;
800821
801- response_json. map_err ( |err| {
822+ let response = response_json. map_err ( |err| {
802823 error ! ( "Failed to deserialize latest application version response {err}" ) ;
803824 Error :: CommandError ( err. to_string ( ) )
804- } )
825+ } ) ?;
826+
827+ info ! ( "Latest application version fetched: {}" , response. version) ;
828+ Ok ( response)
805829 } else {
806830 let err = res. err ( ) . unwrap ( ) ;
807831 error ! ( "Failed to fetch latest application version {err}" ) ;
0 commit comments