summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorDjalal Harouni <tixxdz@opendz.org>2017-04-23 01:03:42 +0200
committerGitHub <noreply@github.com>2017-04-23 01:03:42 +0200
commit74e941c0226a04e2c6b80dd149d0f55e518481ed (patch)
treecffadb1c7096b0209e01fa676e74ad301b1985c7 /src/basic
parent56744c037da0ba2032fba0c7ac116317bb5ae4ae (diff)
parentae2173d66b8b9fc42f311d8586a3cf4abcc65a76 (diff)
Merge pull request #5774 from keszybz/printf-annotations
Printf annotation improvements
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/log.c13
-rw-r--r--src/basic/log.h19
2 files changed, 24 insertions, 8 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 36efc9ac7d..0d0ced00bd 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -553,7 +553,7 @@ static int write_to_journal(
return 1;
}
-static int log_dispatch(
+int log_dispatch_internal(
int level,
int error,
const char *file,
@@ -653,7 +653,7 @@ int log_dump_internal(
if (_likely_(LOG_PRI(level) > log_max_level))
return -error;
- return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
+ return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
}
int log_internalv(
@@ -680,7 +680,7 @@ int log_internalv(
vsnprintf(buffer, sizeof(buffer), format, ap);
- return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
+ return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buffer);
}
int log_internal(
@@ -744,7 +744,8 @@ int log_object_internalv(
vsnprintf(b, l, format, ap);
- return log_dispatch(level, error, file, line, func, object_field, object, extra_field, extra, buffer);
+ return log_dispatch_internal(level, error, file, line, func,
+ object_field, object, extra_field, extra, buffer);
}
int log_object_internal(
@@ -788,7 +789,7 @@ static void log_assert(
log_abort_msg = buffer;
- log_dispatch(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
+ log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
}
noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
@@ -943,7 +944,7 @@ int log_struct_internal(
if (!found)
return -error;
- return log_dispatch(level, error, file, line, func, NULL, NULL, NULL, NULL, buf + 8);
+ return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, buf + 8);
}
int log_set_target_from_string(const char *e) {
diff --git a/src/basic/log.h b/src/basic/log.h
index 72714e02e5..b3e4060b5d 100644
--- a/src/basic/log.h
+++ b/src/basic/log.h
@@ -75,6 +75,18 @@ void log_close_console(void);
void log_parse_environment(void);
+int log_dispatch_internal(
+ int level,
+ int error,
+ const char *file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *extra,
+ const char *extra_field,
+ char *buffer);
+
int log_internal(
int level,
int error,
@@ -115,7 +127,7 @@ int log_object_internalv(
const char *extra_field,
const char *extra,
const char *format,
- va_list ap) _printf_(9,0);
+ va_list ap) _printf_(10,0);
int log_struct_internal(
int level,
@@ -137,7 +149,7 @@ int log_format_iovec(
bool newline_separator,
int error,
const char *format,
- va_list ap);
+ va_list ap) _printf_(6, 0);
/* This modifies the buffer passed! */
int log_dump_internal(
@@ -167,6 +179,9 @@ void log_assert_failed_return(
int line,
const char *func);
+#define log_dispatch(level, error, buffer) \
+ log_dispatch_internal(level, error, __FILE__, __LINE__, __func__, NULL, NULL, NULL, NULL, buffer)
+
/* Logging with level */
#define log_full_errno(level, error, ...) \
({ \