From fb8361d11bdf8c21d2e9d3b94bae444089ba0d96 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Fri, 26 Sep 2025 17:58:31 +0200 Subject: log read and write failures --- src/administration_writer.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/administration_writer.cpp') diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index 75f5daf..c27b3e3 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -122,7 +122,8 @@ static bool _administration_writer_delete_entry_by_name(char* entry) if (zip_entries_delete(zip_write, indices, 1) < 0) result = 0; zip_close(zip_write); - log_add("Deleted entry '%s' in %.3fms.", entry, STOPWATCH_TIME); + if (result) log_info("Deleted entry '%s' in %.3fms.", entry, STOPWATCH_TIME); + else log_error("Failed to delete entry '%s'.", entry); return result; } @@ -487,7 +488,9 @@ bool administration_writer_save_invoice_blocking(invoice inv) free(file_content); - log_add("Saved invoice '%s' in %.3fms.", inv.sequential_number, STOPWATCH_TIME); + if (result) log_info("Saved invoice '%s' in %.3fms.", inv.sequential_number, STOPWATCH_TIME); + else log_error("Failed to save invoice '%s'.", inv.sequential_number); + return result; } @@ -535,7 +538,9 @@ bool administration_writer_save_project_blocking(project project) free(file_content); - log_add("Saved project '%s' in %.3fms.", project.description, STOPWATCH_TIME); + if (result) log_info("Saved project '%s' in %.3fms.", project.description, STOPWATCH_TIME); + else log_error("Failed to save project '%s'.", project.description); + return result; } @@ -581,7 +586,9 @@ bool administration_writer_save_cost_center_blocking(cost_center cost) free(file_content); - log_add("Saved cost center '%s' in %.3fms.", cost.code, STOPWATCH_TIME); + if (result) log_info("Saved cost center '%s' in %.3fms.", cost.code, STOPWATCH_TIME); + else log_error("Failed to save cost center '%s'.", cost.code); + return result; } @@ -628,7 +635,9 @@ bool administration_writer_save_tax_rate_blocking(tax_rate rate) free(file_content); - log_add("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME); + if (result) log_info("Saved tax rate '%s/%.1f' in %.3fms.", rate.country_code, rate.rate, STOPWATCH_TIME); + else log_error("Failed to save tax rate '%s/%.1f'.", rate.country_code, rate.rate); + return result; } @@ -686,7 +695,9 @@ bool administration_writer_save_contact_blocking(contact c) free(file_content); - log_add("Saved contact '%s' in %.3fms.", c.name, STOPWATCH_TIME); + if (result) log_info("Saved contact '%s' in %.3fms.", c.name, STOPWATCH_TIME); + else log_error("Failed to save contact '%s'.", c.name); + return result; } @@ -735,7 +746,9 @@ bool administration_writer_save_all_administration_info_blocking() free(file_content); - log_add("Saved administration info in %.3fms.", STOPWATCH_TIME); + if (result) log_info("Saved administration info in %.3fms.", STOPWATCH_TIME); + else log_error("Failed to save administration info."); + return result; } -- cgit v1.2.3-70-g09d2