Skip to content

Commit

Permalink
fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 1, 2024
1 parent 96bab17 commit 718e877
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ arc_with_non_send_sync = "allow"
blocks_in_conditions = "allow"
get_first = "allow"
doc_lazy_continuation = "allow"
len_zero = "allow"

[workspace]
members = [
Expand Down
9 changes: 0 additions & 9 deletions core/payment-driver/erc20/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,6 @@ impl Erc20Driver {
GenericError::new(format!("Malformed tx.tx_hash: {:?} {err}", tx_hash))
})?;

log::info!("name: {}", &self.get_name());
log::info!("platform: {}", platform);
log::info!(
"payment_id: {}",
token_transfer.payment_id.as_ref().unwrap()
);
log::info!("payment_details: {}", payment_details);
log::info!("confirmation: 0x{}", hex::encode(&transaction_hash));

let Some(payment_id) = &token_transfer.payment_id else {
return Err(GenericError::new("token_transfer.payment_id is null"));
};
Expand Down
2 changes: 1 addition & 1 deletion core/payment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ test-context = "0.1.4"
url = "2.5"

[lints]
workspace = true
workspace = true
2 changes: 1 addition & 1 deletion core/payment/src/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl BatchCycleTask {
//do not sleep for more than 5 minutes
let diff = std::cmp::min(diff, 1000 * 60 * 5);
if diff > 0 {
log::info!(
log::debug!(
"Sleeping for {} before next process for owner_id: {}, platform: {}",
humantime::format_duration(std::time::Duration::from_secs_f64((diff as f64 / 1000.0).round())),
node_id,
Expand Down
20 changes: 12 additions & 8 deletions core/payment/src/dao/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ pub fn resolve_invoices_agreement_part(
String,
BigDecimalField,
)>(conn)?;
log::info!("found [{}] invoices", invoices.len());
if invoices.len() > 0 {
log::info!("found [{}] invoices", invoices.len());
}

let zero = BigDecimal::from(0u32);
for (
Expand Down Expand Up @@ -237,7 +239,9 @@ pub fn resolve_invoices_activity_part(
.bind::<Text, _>(owner_id)
.load::<ActivityJoinAgreement>(conn)?;

log::info!("Pay for activities - {} found to check", query_res.len());
if query_res.len() > 0 {
log::info!("Pay for activities - {} found to check", query_res.len());
}
for a in query_res {
let amount_to_pay =
a.total_amount_accepted.0.clone() - a.total_amount_scheduled.0.clone();
Expand Down Expand Up @@ -521,9 +525,7 @@ pub fn resolve_invoices(args: &ResolveInvoiceArgs) -> DbResult<Option<String>> {

let total_amount = BigDecimal::from(0u32);

log::info!("Resolve invoices: {} - {}", owner_id.to_string(), platform);

log::debug!("Resolving invoices for {}", owner_id);
log::debug!("Resolving invoices for {} - {}", owner_id, platform);
let (payments, total_amount) = resolve_invoices_activity_part(args, total_amount, payments)?;

log::debug!("Resolving agreements for {}", owner_id);
Expand Down Expand Up @@ -551,7 +553,9 @@ pub fn resolve_invoices(args: &ResolveInvoiceArgs) -> DbResult<Option<String>> {
.load(conn)?;
let mut expenditures = expenditures_orig.clone();

log::info!("Found total of {} expenditures", expenditures.len());
if expenditures.len() > 0 {
log::debug!("Found total of {} expenditures", expenditures.len());
}

let payments_allocations =
use_expenditures_on_payments(&mut expenditures, payments).map_err(|e| {
Expand All @@ -562,7 +566,7 @@ pub fn resolve_invoices(args: &ResolveInvoiceArgs) -> DbResult<Option<String>> {
// upload the updated expenditures to database (if changed)
for (expenditure_new, expenditure_old) in zip(expenditures.iter(), expenditures_orig.iter()) {
if expenditure_new.scheduled_amount != expenditure_old.scheduled_amount {
log::info!("Updating expenditure {:?}", expenditure_new);
log::debug!("Updating expenditure {:?}", expenditure_new);
let mut query = diesel::update(pae_dsl::pay_allocation_expenditure)
.filter(pae_dsl::owner_id.eq(&expenditure_new.owner_id))
.filter(pae_dsl::allocation_id.eq(&expenditure_new.allocation_id))
Expand All @@ -577,7 +581,7 @@ pub fn resolve_invoices(args: &ResolveInvoiceArgs) -> DbResult<Option<String>> {
.set(pae_dsl::scheduled_amount.eq(&expenditure_new.scheduled_amount))
.execute(conn)?;
} else {
log::info!("Expenditure {:?} not changed", expenditure_new);
log::debug!("Expenditure {:?} not changed", expenditure_new);
}
}

Expand Down

0 comments on commit 718e877

Please sign in to comment.