chiark / gitweb /
util: unify SO_PEERCRED/SO_PEERSEC invocations
[elogind.git] / src / shared / log.h
index 979f833d571a8c7a11307714d3194ce017392bef..3dcfa113085b419a9bac1bbeade37e9acfdcdc54 100644 (file)
@@ -75,7 +75,7 @@ int log_meta(
                 const char*file,
                 int line,
                 const char *func,
-                const char *format, ...) _printf_attr_(5,6);
+                const char *format, ...) _printf_(5,6);
 
 int log_metav(
                 int level,
@@ -83,7 +83,7 @@ int log_metav(
                 int line,
                 const char *func,
                 const char *format,
-                va_list ap) _printf_attr_(5,0);
+                va_list ap) _printf_(5,0);
 
 int log_meta_object(
                 int level,
@@ -92,7 +92,7 @@ int log_meta_object(
                 const char *func,
                 const char *object_name,
                 const char *object,
-                const char *format, ...) _printf_attr_(7,8);
+                const char *format, ...) _printf_(7,8);
 
 int log_metav_object(
                 int level,
@@ -102,14 +102,14 @@ int log_metav_object(
                 const char *object_name,
                 const char *object,
                 const char *format,
-                va_list ap) _printf_attr_(7,0);
+                va_list ap) _printf_(7,0);
 
 int log_struct_internal(
                 int level,
                 const char *file,
                 int line,
                 const char *func,
-                const char *format, ...) _printf_attr_(5,0) _sentinel_;
+                const char *format, ...) _printf_(5,0) _sentinel_;
 
 int log_oom_internal(
                 const char *file,
@@ -124,25 +124,35 @@ int log_dump_internal(
                 const char *func,
                 char *buffer);
 
-_noreturn_ void log_assert_failed(
+noreturn void log_assert_failed(
                 const char *text,
                 const char *file,
                 int line,
                 const char *func);
 
-_noreturn_ void log_assert_failed_unreachable(
+noreturn void log_assert_failed_unreachable(
                 const char *text,
                 const char *file,
                 int line,
                 const char *func);
 
-#define log_full(level, ...) log_meta(level,   __FILE__, __LINE__, __func__, __VA_ARGS__)
+void log_assert_failed_return(
+                const char *text,
+                const char *file,
+                int line,
+                const char *func);
 
-#define log_debug(...)   log_meta(LOG_DEBUG,   __FILE__, __LINE__, __func__, __VA_ARGS__)
-#define log_info(...)    log_meta(LOG_INFO,    __FILE__, __LINE__, __func__, __VA_ARGS__)
-#define log_notice(...)  log_meta(LOG_NOTICE,  __FILE__, __LINE__, __func__, __VA_ARGS__)
-#define log_warning(...) log_meta(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
-#define log_error(...)   log_meta(LOG_ERR,     __FILE__, __LINE__, __func__, __VA_ARGS__)
+#define log_full(level, ...) \
+do { \
+        if (log_get_max_level() >= (level)) \
+                log_meta((level), __FILE__, __LINE__, __func__, __VA_ARGS__); \
+} while (0)
+
+#define log_debug(...)   log_full(LOG_DEBUG,   __VA_ARGS__)
+#define log_info(...)    log_full(LOG_INFO,    __VA_ARGS__)
+#define log_notice(...)  log_full(LOG_NOTICE,  __VA_ARGS__)
+#define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__)
+#define log_error(...)   log_full(LOG_ERR,     __VA_ARGS__)
 
 #define log_struct(level, ...) log_struct_internal(level, __FILE__, __LINE__, __func__, __VA_ARGS__)