summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2023-09-10 07:31:18 +0200
committerMikhail Burakov <mburakov@mailbox.org>2023-09-10 07:31:18 +0200
commit2841b851e95cc799c50e7a2e843d53dd4f349693 (patch)
treebf5e11f33bcbd435a0ec221780222dd1913eb29c
parent815f6b237437dbd9c143774134838a32997bb2dc (diff)
Add dedicated FROM_HERE macro for logging
-rw-r--r--utils.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/utils.h b/utils.h
index 0207cbe..51db723 100644
--- a/utils.h
+++ b/utils.h
@@ -24,15 +24,15 @@ extern "C" {
#define STR_IMPL(op) #op
#define STR(op) STR_IMPL(op)
+#define FROM_HERE __FILE__ ":" STR(__LINE__)
#define LENGTH(op) (sizeof(op) / sizeof *(op))
-#define LOG(fmt, ...) \
- fprintf(stderr, __FILE__ ":" STR(__LINE__) " " fmt "\n", ##__VA_ARGS__)
+#define LOG(fmt, ...) fprintf(stderr, FROM_HERE " " fmt "\n", ##__VA_ARGS__)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#ifdef USE_SYSLOG_LOGGING
#define LOG(log_level, fmt, ...) \
- LogImpl(log_level, __FILE__ ":" STR(__LINE__) " " fmt "\n", ##__VA_ARGS__)
+ LogImpl(log_level, FROM_HERE " " fmt "\n", ##__VA_ARGS__)
#define LOGD(...) LOG(kLogLevelDebug, __VA_ARGS__)
#define LOGI(...) LOG(kLogLevelInfo, __VA_ARGS__)
#define LOGW(...) LOG(kLogLevelWarning, __VA_ARGS__)