mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-08-05 20:58:29 +02:00
refactor: Simplify the log hinter
Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
@@ -62,6 +62,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_ONCE(type, ...) \
|
||||
do { \
|
||||
static int __once = 0; \
|
||||
if (!__once++) \
|
||||
LOG_##type(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/* Fatal warnings trigger an exit */
|
||||
#define FATAL_ERRORNO(msg) \
|
||||
do { \
|
||||
@@ -74,6 +81,26 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
/* Hinting helpers */
|
||||
#define HINT_ONCE(name, hint) \
|
||||
do { \
|
||||
static int __once = 0; \
|
||||
name = (!__once++ ? hint : ""); \
|
||||
} while (0)
|
||||
|
||||
#define HINT_ONCE_ON(cond, ...) \
|
||||
do { \
|
||||
if (cond) \
|
||||
HINT_ONCE(__VA_ARGS__); \
|
||||
} while (0);
|
||||
|
||||
#define LOG_HINTED(type, msg, hint, ...) \
|
||||
do { \
|
||||
const char *__arg; \
|
||||
HINT_ONCE(__arg, hint); \
|
||||
LOG_##type(msg "%s", __VA_ARGS__, __arg); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Control if and how how we use syslog
|
||||
*/
|
||||
|
Reference in New Issue
Block a user