summaryrefslogtreecommitdiff
path: root/libmisc
diff options
context:
space:
mode:
Diffstat (limited to 'libmisc')
-rw-r--r--libmisc/assert.c10
-rw-r--r--libmisc/include/libmisc/log.h16
-rw-r--r--libmisc/tests/test_log.c10
3 files changed, 18 insertions, 18 deletions
diff --git a/libmisc/assert.c b/libmisc/assert.c
index fdd8154..8bca524 100644
--- a/libmisc/assert.c
+++ b/libmisc/assert.c
@@ -7,7 +7,7 @@
#include <stdbool.h> /* for bool, true, false */
#define LOG_NAME ASSERT
-#include <libmisc/log.h> /* for errorf() */
+#include <libmisc/log.h> /* for log_errorf() */
#include <libmisc/assert.h>
@@ -19,10 +19,10 @@ void __assert_msg_fail(const char *expr,
static bool in_fail = false;
if (!in_fail) {
in_fail = true;
- errorf("%s:%u:%s(): assertion \"%s\" failed%s%s",
- file, line, func,
- expr,
- msg ? ": " : "", msg ?: "");
+ log_errorf("%s:%u:%s(): assertion \"%s\" failed%s%s",
+ file, line, func,
+ expr,
+ msg ? ": " : "", msg ?: "");
in_fail = false;
}
__lm_abort();
diff --git a/libmisc/include/libmisc/log.h b/libmisc/include/libmisc/log.h
index 79c0ab6..4529946 100644
--- a/libmisc/include/libmisc/log.h
+++ b/libmisc/include/libmisc/log.h
@@ -20,15 +20,15 @@
const char *const_byte_str(uint8_t b);
-#define n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
-#define n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
-#define n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \
- __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
+#define log_n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
+#define log_n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
+#define log_n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \
+ __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0)
#endif /* _LIBMISC_LOG_H_ */
-#if defined(LOG_NAME) && !defined(errorf)
-#define errorf(fmt, ...) n_errorf(LOG_NAME, fmt, __VA_ARGS__)
-#define infof(fmt, ...) n_infof(LOG_NAME, fmt, __VA_ARGS__)
-#define debugf(fmt, ...) n_debugf(LOG_NAME, fmt, __VA_ARGS__)
+#if defined(LOG_NAME) && !defined(log_errorf)
+#define log_errorf(fmt, ...) log_n_errorf(LOG_NAME, fmt, __VA_ARGS__)
+#define log_infof(fmt, ...) log_n_infof(LOG_NAME, fmt, __VA_ARGS__)
+#define log_debugf(fmt, ...) log_n_debugf(LOG_NAME, fmt, __VA_ARGS__)
#endif
diff --git a/libmisc/tests/test_log.c b/libmisc/tests/test_log.c
index 49a76ca..02b95d6 100644
--- a/libmisc/tests/test_log.c
+++ b/libmisc/tests/test_log.c
@@ -1,6 +1,6 @@
/* libmisc/tests/test_log.c - Tests for <libmisc/log.h>
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -54,17 +54,17 @@ int __lm_printf(const char *format, ...) {
int main() {
should_print("error: FROBNICATE: val=42\n",
- errorf("val=%d", 42));
+ log_errorf("val=%d", 42));
should_print("info : FROBNICATE: val=0\n",
- infof("val=%d", 0));
+ log_infof("val=%d", 0));
#ifndef NDEBUG
#define CONFIG_FROBNICATE_DEBUG 1
should_print("debug: FROBNICATE: val=-2\n",
- debugf("val=%d", -2));
+ log_debugf("val=%d", -2));
#undef CONFIG_FROBNICATE_DEBUG
#define CONFIG_FROBNICATE_DEBUG 0
should_print(NULL,
- debugf("val=%d", -2));
+ log_debugf("val=%d", -2));
#endif
return 0;
}