@@ -78,7 +78,7 @@ pub async fn disconnect(
78
78
info ! ( "Disconnected from location with id: {location_id}" ) ;
79
79
Ok ( ( ) )
80
80
} 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" ) ;
82
82
Err ( Error :: NotFound )
83
83
}
84
84
}
@@ -130,7 +130,7 @@ pub async fn save_device_config(
130
130
app_state : State < ' _ , AppState > ,
131
131
handle : AppHandle ,
132
132
) -> Result < SaveDeviceConfigResponse , Error > {
133
- debug ! ( "Received device configuration: {response:#?}" ) ;
133
+ debug ! ( "Received device configuration: {response:#?}. " ) ;
134
134
135
135
let mut transaction = app_state. get_pool ( ) . begin ( ) . await ?;
136
136
let instance_info = response
@@ -168,6 +168,7 @@ pub async fn save_device_config(
168
168
locations,
169
169
instance,
170
170
} ;
171
+ info ! ( "Device configuration saved." ) ;
171
172
Ok ( res)
172
173
}
173
174
@@ -309,6 +310,7 @@ pub async fn update_instance(
309
310
let mut transaction = pool. begin ( ) . await ?;
310
311
311
312
// update instance
313
+ debug ! ( "Updating instance {instance_id}." ) ;
312
314
let instance_info = response
313
315
. instance
314
316
. expect ( "Missing instance info in device config response" ) ;
@@ -319,6 +321,7 @@ pub async fn update_instance(
319
321
instance. save ( & mut * transaction) . await ?;
320
322
321
323
// process locations received in response
324
+ debug ! ( "Updating locations for instance {instance_id}." ) ;
322
325
for location in response. configs {
323
326
// parse device config
324
327
let mut new_location = device_config_to_location ( location, instance_id) ;
@@ -330,6 +333,10 @@ pub async fn update_instance(
330
333
{
331
334
// remove from list of existing locations
332
335
let mut current_location = current_locations. remove ( position) ;
336
+ debug ! (
337
+ "Updating existing location {} for instance {instance_id}." ,
338
+ current_location. name
339
+ ) ;
333
340
// update existing location
334
341
current_location. name = new_location. name ;
335
342
current_location. address = new_location. address ;
@@ -339,17 +346,26 @@ pub async fn update_instance(
339
346
current_location. mfa_enabled = new_location. mfa_enabled ;
340
347
current_location. keepalive_interval = new_location. keepalive_interval ;
341
348
current_location. save ( & mut * transaction) . await ?;
349
+ info ! (
350
+ "Location {} updated for instance {instance_id}." ,
351
+ current_location. name
352
+ ) ;
342
353
} else {
343
354
// create new location
355
+ debug ! ( "Creating new location for instance {instance_id}." ) ;
344
356
new_location. save ( & mut * transaction) . await ?;
357
+ info ! ( "New location created for instance {instance_id}." ) ;
345
358
}
346
359
}
360
+ info ! ( "Locations updated for instance {instance_id}." ) ;
347
361
348
362
// remove locations which were present in current locations
349
363
// but no longer found in core response
364
+ debug ! ( "Removing locations for instance {instance_id}." ) ;
350
365
for removed_location in current_locations {
351
366
removed_location. delete ( & mut * transaction) . await ?;
352
367
}
368
+ info ! ( "Locations removed for instance {instance_id}." ) ;
353
369
354
370
transaction. commit ( ) . await ?;
355
371
@@ -456,7 +472,7 @@ pub async fn all_connections(
456
472
. collect ( )
457
473
}
458
474
} ;
459
- debug ! ( "Connections received, returning." ) ;
475
+ info ! ( "Connections retrieved({})" , connections . len ( ) ) ;
460
476
trace ! ( "Connections found:\n {:#?}" , connections) ;
461
477
Ok ( connections)
462
478
}
@@ -469,7 +485,7 @@ pub async fn all_tunnel_connections(
469
485
debug ! ( "Retrieving connections for location {location_id}" ) ;
470
486
let connections =
471
487
TunnelConnectionInfo :: all_by_tunnel_id ( & app_state. get_pool ( ) , location_id) . await ?;
472
- debug ! ( "Connections received, returning." ) ;
488
+ info ! ( "Tunnel connections retrieved({})" , connections . len ( ) ) ;
473
489
trace ! ( "Connections found:\n {:#?}" , connections) ;
474
490
Ok ( connections)
475
491
}
@@ -487,8 +503,8 @@ pub async fn active_connection(
487
503
if connection. is_some ( ) {
488
504
debug ! ( "Active connection found" ) ;
489
505
}
490
- trace ! ( "Connection:\n {:#?}" , connection) ;
491
- debug ! ( "Connection returned " ) ;
506
+ trace ! ( "Connection retrieved :\n {:#?}" , connection) ;
507
+ info ! ( "Connection retrieved " ) ;
492
508
Ok ( connection)
493
509
}
494
510
@@ -503,18 +519,18 @@ pub async fn last_connection(
503
519
if let Some ( connection) =
504
520
Connection :: latest_by_location_id ( & app_state. get_pool ( ) , location_id) . await ?
505
521
{
506
- trace ! ( "Connection found" ) ;
522
+ info ! ( "Found last connection at {}" , connection . end ) ;
507
523
Ok ( Some ( connection. into ( ) ) )
508
524
} else {
509
525
Ok ( None )
510
526
}
511
527
} else if let Some ( connection) =
512
528
TunnelConnection :: latest_by_tunnel_id ( & app_state. get_pool ( ) , location_id) . await ?
513
529
{
514
- trace ! ( "Connection found" ) ;
530
+ info ! ( "Found last connection at {}" , connection . end ) ;
515
531
Ok ( Some ( connection. into ( ) ) )
516
532
} else {
517
- trace ! ( "No last connection found" ) ;
533
+ info ! ( "No last connection found" ) ;
518
534
Ok ( None )
519
535
}
520
536
}
@@ -536,7 +552,7 @@ pub async fn update_location_routing(
536
552
{
537
553
location. route_all_traffic = route_all_traffic;
538
554
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}" ) ;
540
556
handle. emit_all (
541
557
"location-update" ,
542
558
Payload {
@@ -556,7 +572,7 @@ pub async fn update_location_routing(
556
572
{
557
573
tunnel. route_all_traffic = route_all_traffic;
558
574
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}" ) ;
560
576
handle. emit_all (
561
577
"location-update" ,
562
578
Payload {
@@ -577,6 +593,7 @@ pub async fn get_settings(handle: AppHandle) -> Result<Settings, Error> {
577
593
debug ! ( "Retrieving settings" ) ;
578
594
let app_state = handle. state :: < AppState > ( ) ;
579
595
let settings = Settings :: get ( & app_state. get_pool ( ) ) . await ?;
596
+ info ! ( "Settings retrieved" ) ;
580
597
Ok ( settings)
581
598
}
582
599
@@ -595,7 +612,7 @@ pub async fn update_settings(data: SettingsPatch, handle: AppHandle) -> Result<S
595
612
Ok ( _) => { }
596
613
Err ( e) => {
597
614
error ! (
598
- "During settings update, tray configuration update failed . err : {}" ,
615
+ "Tray configuration update failed during settings update . err : {}" ,
599
616
e. to_string( )
600
617
) ;
601
618
}
@@ -632,7 +649,7 @@ pub async fn delete_instance(instance_id: i64, handle: AppHandle) -> Result<(),
632
649
error ! ( "{msg}" ) ;
633
650
Error :: InternalError ( msg)
634
651
} ) ?;
635
- debug ! ( "Connection closed and interface removed" ) ;
652
+ info ! ( "Connection closed and interface removed" ) ;
636
653
}
637
654
}
638
655
}
@@ -648,10 +665,12 @@ pub async fn delete_instance(instance_id: i64, handle: AppHandle) -> Result<(),
648
665
#[ tauri:: command( async ) ]
649
666
pub async fn parse_tunnel_config ( config : String ) -> Result < Tunnel , Error > {
650
667
debug ! ( "Parsing config file" ) ;
651
- parse_wireguard_config ( & config) . map_err ( |error| {
668
+ let tunnel_config = parse_wireguard_config ( & config) . map_err ( |error| {
652
669
error ! ( "{error}" ) ;
653
670
Error :: ConfigParseError ( error. to_string ( ) )
654
- } )
671
+ } ) ?;
672
+ info ! ( "Config file parsed" ) ;
673
+ Ok ( tunnel_config)
655
674
}
656
675
#[ tauri:: command( async ) ]
657
676
pub 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
700
719
connection_type : ConnectionType :: Tunnel ,
701
720
} )
702
721
}
722
+
723
+ info ! ( "Tunnels retrieved({})" , tunnel_info. len( ) ) ;
703
724
Ok ( tunnel_info)
704
725
}
705
726
#[ tauri:: command( async ) ]
@@ -710,7 +731,7 @@ pub async fn tunnel_details(
710
731
debug ! ( "Retrieving Tunnel with ID {tunnel_id}." ) ;
711
732
712
733
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}" ) ;
714
735
Ok ( tunnel)
715
736
} else {
716
737
error ! ( "Tunnel with ID: {tunnel_id}, not found" ) ;
@@ -745,7 +766,7 @@ pub async fn delete_tunnel(tunnel_id: i64, handle: AppHandle) -> Result<(), Erro
745
766
error ! ( "{msg}" ) ;
746
767
Error :: InternalError ( msg)
747
768
} ) ?;
748
- debug ! ( "Connection closed and interface removed" ) ;
769
+ info ! ( "Connection closed and interface removed" ) ;
749
770
}
750
771
tunnel. delete ( pool) . await ?;
751
772
} else {
@@ -798,10 +819,13 @@ pub async fn get_latest_app_version(handle: AppHandle) -> Result<AppVersionInfo,
798
819
let response_json: Result < AppVersionInfo , reqwest:: Error > =
799
820
response. json :: < AppVersionInfo > ( ) . await ;
800
821
801
- response_json. map_err ( |err| {
822
+ let response = response_json. map_err ( |err| {
802
823
error ! ( "Failed to deserialize latest application version response {err}" ) ;
803
824
Error :: CommandError ( err. to_string ( ) )
804
- } )
825
+ } ) ?;
826
+
827
+ info ! ( "Latest application version fetched: {}" , response. version) ;
828
+ Ok ( response)
805
829
} else {
806
830
let err = res. err ( ) . unwrap ( ) ;
807
831
error ! ( "Failed to fetch latest application version {err}" ) ;
0 commit comments