refactor: standardize error reporting on the log module

- Add log_perror() helper (context + strerror(errno)) to the log module
- Replace all bare perror() calls with log_perror() so errors are routed
  through the unified logger (stderr sink + optional --log-file sink)
- Convert fprintf(stderr, "Error:/Warning: ...") in client code to
  log_message(); raw fprintf kept only for progress/stats output
This commit is contained in:
2026-08-30 14:06:48 +02:00
parent ae95211a05
commit 6d82967c68
16 changed files with 86 additions and 73 deletions
+3 -3
View File
@@ -20,7 +20,7 @@
Chunk* chunk_create(File** items, int element_count) {
Chunk* chunk = (Chunk*)malloc(sizeof(Chunk));
if (chunk == NULL) {
perror("ERROR: Could not allocate memory for chunk structure");
log_perror("ERROR: Could not allocate memory for chunk structure");
return NULL;
}
@@ -118,7 +118,7 @@ Chunk* chunk_deserialize(Data* data, bool use_metadata) {
char* path = malloc(path_len + 1);
if (path == NULL) {
perror("Could not allocate memory for file path");
log_perror("Could not allocate memory for file path");
array_list_delete(files);
return NULL;
}
@@ -191,7 +191,7 @@ Chunk* chunk_deserialize(Data* data, bool use_metadata) {
void* file_data = malloc(file_data_size > 0 ? file_data_size : 1);
if (file_data == NULL) {
perror("Could not allocate memory for file data");
log_perror("Could not allocate memory for file data");
file_destroy(file);
array_list_delete(files);
return NULL;