1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

log: introduce log_metav

This commit is contained in:
Lennart Poettering 2012-03-14 14:54:41 +01:00
parent 0d1575814b
commit 17a949114d
2 changed files with 35 additions and 13 deletions

View File

@ -582,6 +582,30 @@ int log_dump_internal(
return r;
}
int log_metav(
int level,
const char*file,
int line,
const char *func,
const char *format,
va_list ap) {
char buffer[LINE_MAX];
int saved_errno, r;
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
saved_errno = errno;
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
r = log_dispatch(level, file, line, func, buffer);
errno = saved_errno;
return r;
}
int log_meta(
int level,
const char*file,
@ -589,24 +613,13 @@ int log_meta(
const char *func,
const char *format, ...) {
char buffer[LINE_MAX];
int saved_errno, r;
int r;
va_list ap;
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
saved_errno = errno;
va_start(ap, format);
vsnprintf(buffer, sizeof(buffer), format, ap);
r = log_metav(level, file, line, func, format, ap);
va_end(ap);
char_array_0(buffer);
r = log_dispatch(level, file, line, func, buffer);
errno = saved_errno;
return r;
}

View File

@ -24,6 +24,7 @@
#include <syslog.h>
#include <stdbool.h>
#include <stdarg.h>
#include "macro.h"
@ -73,6 +74,14 @@ int log_meta(
const char *func,
const char *format, ...) _printf_attr_(5,6);
int log_metav(
int level,
const char*file,
int line,
const char *func,
const char *format,
va_list ap);
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func);
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func);