summaryrefslogtreecommitdiffstats
path: root/src/log.h
diff options
context:
space:
mode:
authorGravatar Visual Ehrmanntraut2025-06-27 12:16:04 +0300
committerGravatar Nikias Bassen2025-06-27 16:18:29 +0200
commit8d0563380db8f3412de1fabf5ad74ccde1159eac (patch)
tree19204b6810e361a6c530d7e720b7c018485445e6 /src/log.h
parent8061f08b4e0a8f0ab5d1548b7e9978f3cc8647a2 (diff)
downloadidevicerestore-8d0563380db8f3412de1fabf5ad74ccde1159eac.tar.gz
idevicerestore-8d0563380db8f3412de1fabf5ad74ccde1159eac.tar.bz2
Improve type safety of new logging system and its handling of varargs
- Replaced loglevel arguments and globals using the `int` type with the `loglevel` enum. - Moved logging print func handler function declaration to typedef. - Fixed misuse of `print_func` where a char* was passed in place of `va_list` via a wrapper function `print_funcf`. - Fixed reuse of varargs in `logger` causing a segfault when `stderr_enabled` is true. - Fixed length in `snprintf` call inside `logger_hex_dump` truncating the printed text.
Diffstat (limited to 'src/log.h')
-rw-r--r--src/log.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/log.h b/src/log.h
index 80642c0..ad3da14 100644
--- a/src/log.h
+++ b/src/log.h
@@ -30,11 +30,13 @@ enum loglevel {
LL_DEBUG
};
-extern int log_level;
+extern enum loglevel log_level;
+
+typedef void (*logger_print_func)(enum loglevel level, const char*, va_list);
void logger(enum loglevel level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
int logger_set_logfile(const char* path);
-void logger_set_print_func(void (*func)(int level, const char*, va_list));
+void logger_set_print_func(logger_print_func func);
void logger_dump_hex(enum loglevel level, const void* buf, unsigned int len);
void logger_dump_plist(enum loglevel level, plist_t plist, int human_readable);