logging: strip down and clean `log.h` and `log.c`
[babeltrace.git] / src / common / common.h
index b447ec889e51fa68d2ed5963b073b95759aec8f2..bf3a83887b3fea8b9cea8a54d5b92a72af806151 100644 (file)
@@ -378,13 +378,20 @@ int bt_common_append_file_content_to_g_string(GString *str, FILE *fp);
 
 void bt_common_abort(void) __attribute__((noreturn));
 
+#if (!defined(BT_LOG_WRITE_CUR_LVL) && !defined(BT_LOG_WRITE_ERRNO_CUR_LVL))
+#define BT_LOG_LEVEL_UNUSED_ATTR __attribute__((unused))
+#else
+#define BT_LOG_LEVEL_UNUSED_ATTR
+#endif
+
 /*
  * Wraps read() function to handle EINTR and partial reads.
  * On success, it returns `count` received as parameter. On error, it returns a
  * value smaller than the requested `count`.
  */
 static inline
-ssize_t bt_common_read(int fd, void *buf, size_t count, int log_level)
+ssize_t bt_common_read(int fd, void *buf, size_t count,
+               int log_level BT_LOG_LEVEL_UNUSED_ATTR)
 {
        size_t i = 0;
        ssize_t ret;
@@ -406,8 +413,8 @@ ssize_t bt_common_read(int fd, void *buf, size_t count, int log_level)
                                /* retry operation */
                                continue;
                        } else {
-#ifdef BT_LOG_WRITE_ERRNO_CUR_LVL
-                               BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR,
+#ifdef BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL
+                               BT_LOG_WRITE_ERRNO_PRINTF_CUR_LVL(BT_LOG_ERROR,
                                        log_level, BT_LOG_TAG,
                                        "Error while reading", ": fd=%d", fd);
 #endif
This page took 0.033685 seconds and 4 git commands to generate.