@@ -358,6 +358,16 @@ struct Payment {
358
358
dispatch_time : SystemTime ,
359
359
}
360
360
361
+ impl Payment {
362
+ fn formatted_activity_name ( & self ) -> String {
363
+ if self . activity_name != "" {
364
+ format ! ( "{} activity:" , self . activity_name)
365
+ } else {
366
+ "" . to_string ( )
367
+ }
368
+ }
369
+ }
370
+
361
371
impl Display for Payment {
362
372
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
363
373
let dispatch_time = self
@@ -367,8 +377,8 @@ impl Display for Payment {
367
377
368
378
write ! (
369
379
f,
370
- "{} activity: Payment {} dispatched at {:?} sending {} msat from {} -> {}" ,
371
- self . activity_name ,
380
+ "{} Payment {} dispatched at {:?} sending {} msat from {} -> {}" ,
381
+ self . formatted_activity_name ( ) ,
372
382
self . hash. map( |h| hex:: encode( h. 0 ) ) . unwrap_or_default( ) ,
373
383
dispatch_time,
374
384
self . amount_msat,
@@ -1118,20 +1128,17 @@ impl PaymentResultLogger {
1118
1128
}
1119
1129
1120
1130
self . total_sent += details. amount_msat ;
1121
- self . activity_name = details. activity_name . clone ( ) ;
1131
+ self . activity_name = details. formatted_activity_name ( ) ;
1122
1132
}
1123
1133
}
1124
1134
1125
- // TODO: Add activity name and handle the initial processing log with few LOC
1126
1135
impl Display for PaymentResultLogger {
1127
1136
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
1128
1137
let total_payments = self . success_payment + self . failed_payment ;
1129
1138
1130
- // if self.activity_name
1131
-
1132
1139
write ! (
1133
1140
f,
1134
- "{} activity: Processed {} payments sending {} msat total with {:.2}% success rate." ,
1141
+ "{} Processed {} payments sending {} msat total with {:.2}% success rate." ,
1135
1142
self . activity_name,
1136
1143
total_payments,
1137
1144
self . total_sent,
0 commit comments