diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-15 02:07:05 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-15 02:07:05 +0000 |
| commit | 3980d30d28951edcc34d16758d549bc4d4ab193e (patch) | |
| tree | e61209c44cf875e59598782c41c9d35083124bc2 /include/util | |
| parent | af69219a7229ccf524987123b2ecd70ff0456c9f (diff) | |
add safe_logger, and prepare for logical operators
Diffstat (limited to 'include/util')
| -rw-r--r-- | include/util/io.h | 16 |
1 files changed, 16 insertions, 0 deletions
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 <typename ...T_arg> +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); |
