fix logging bug

This commit is contained in:
2025-05-06 22:50:49 +03:00
parent a5e723364f
commit c7ff4f8813
2 changed files with 6 additions and 3 deletions

View File

@@ -54,6 +54,9 @@ HiResult file_copy(const char *srcname, const char *destination) {
goto cleanup; goto cleanup;
} }
// BUG: Maybe. Sometimes the copied file is 0 bytes with no clear errors.
// Maybe bytes_read ends up being 0 without it being an error condition,
// so ferror doesn't get flagged.
char buffer[HI_FILE_BUFFER_SIZE]; char buffer[HI_FILE_BUFFER_SIZE];
size_t bytes_read = 0; size_t bytes_read = 0;
while ((bytes_read = fread(buffer, 1, sizeof buffer, src)) > 0) { while ((bytes_read = fread(buffer, 1, sizeof buffer, src)) > 0) {
@@ -64,7 +67,7 @@ HiResult file_copy(const char *srcname, const char *destination) {
} }
if (ferror(src)) { if (ferror(src)) {
log_error("Error reading from source: %s\n"); log_error("Error reading from source: %s\n", strerror(errno));
goto cleanup; goto cleanup;
} }

View File

@@ -215,8 +215,8 @@ int hi_init(size_t n, const char **enabled_modules) {
fprintf(stderr, "Failed to init logger.\n"); fprintf(stderr, "Failed to init logger.\n");
return 1; return 1;
} }
log_set_level("DEBUG"); log_set_level("WARNING");
log_set_thread_name("Main"); log_set_thread_name("Hiload");
// Start the filewatcher // Start the filewatcher
context.filewatcher = filewatcher_create(); context.filewatcher = filewatcher_create();