From 3980d30d28951edcc34d16758d549bc4d4ab193e Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 15 Sep 2026 02:07:05 +0000 Subject: add safe_logger, and prepare for logical operators --- include/util/io.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/util/io.h') diff --git a/include/util/io.h b/include/util/io.h index e995af5..5c0a129 100644 --- a/include/util/io.h +++ b/include/util/io.h @@ -99,6 +99,22 @@ void safe_output(T x, T_arg ...arg) errno = errno_old; } +// async-signal-safe output function +// example: +// safe_output("string", 123, variable); +template +void safe_logger(T_arg ...arg) +{ + int errno_old = errno; + + if (GLOBAL_DEBUG && verbose) + { + safe_output(arg...); + } + + errno = errno_old; +} + void unix_error(const char *msg); void app_error(const char *msg); -- cgit v1.3.1-4-g156e