summaryrefslogtreecommitdiff
path: root/src/basic/log.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-04-21 12:52:54 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-04-21 13:39:03 -0400
commit93484b4790e261ac3dab12cba5b20d33c74a9202 (patch)
treececfdbf4b68b6258a3b929aaecf0f67fac8f1033 /src/basic/log.c
parentba360bb05ce9b0bb86821fcdfebf66ccd9f7efd5 (diff)
downloadsystemd-93484b4790e261ac3dab12cba5b20d33c74a9202.tar.gz
basic/log: expose log_dispatch
This is useful when we want to avoid printf formatting on the message. It's nicer than using log_struct with "%s" as the format, because printf is slow and with a large message (like from a backtrace) this would require extra unnecessary memory. I'm not exposing all the fields in the wrapper: only level and errno. Those are the most likely to be useful.
Diffstat (limited to 'src/basic/log.c')
-rw-r--r--src/basic/log.c13
1 files changed, 7 insertions, 6 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) {