util/log: Add support for logging once.
These are not data-race safe (like many other once patterns in Mesa), so they might not log exactly once, but it should be good enough for not spamming the console. Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14999>
This commit is contained in:
parent
ad0fcaf1ee
commit
04cdd41fdc
|
@ -68,6 +68,21 @@ mesa_log_v(enum mesa_log_level, const char *tag, const char *format,
|
|||
#define mesa_logd_v(fmt, va) __mesa_log_use_args((fmt), (va))
|
||||
#endif
|
||||
|
||||
#define mesa_log_once(level, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
static bool once; \
|
||||
if (!once) { \
|
||||
once = true; \
|
||||
mesa_log(level, (MESA_LOG_TAG), fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define mesa_loge_once(fmt, ...) mesa_log_once(MESA_LOG_ERROR, fmt, ##__VA_ARGS__)
|
||||
#define mesa_logw_once(fmt, ...) mesa_log_once(MESA_LOG_WARN, fmt, ##__VA_ARGS__)
|
||||
#define mesa_logi_once(fmt, ...) mesa_log_once(MESA_LOG_INFO, fmt, ##__VA_ARGS__)
|
||||
#define mesa_logd_once(fmt, ...) mesa_log_once(MESA_LOG_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
struct log_stream {
|
||||
char *msg;
|
||||
const char *tag;
|
||||
|
|
Loading…
Reference in New Issue