aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-10-08 14:52:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-10-08 14:52:21 +0000
commit1c9d98d57e35a8db3deaa1ba1951b4ee9dc1d149 (patch)
tree8dd341d68bf01b91ff3fc34991dc8e1401c97039
parentshm: move definition of FOOT_MFD_FLAGS to the top (diff)
config: log_contextual_errno(): sync with log_contextual()
... in terms of whether to print section/value separators
-rw-r--r--config.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/config.c b/config.c
index e5ebb558..4722cfdd 100644
--- a/config.c
+++ b/config.c
@@ -283,10 +283,19 @@ log_contextual_errno(struct context *ctx, const char *file, int lineno,
char *formatted_msg = xvasprintf(fmt, va);
va_end(va);
+ bool print_dot = ctx->key != NULL;
+ bool print_colon = ctx->value != NULL;
+
+ if (!print_dot)
+ ctx->key = "";
+
+ if (!print_colon)
+ ctx->value = "";
+
log_and_notify_errno(
- ctx->conf, file, lineno, "%s:%d: [%s].%s: %s: %s",
- ctx->path, ctx->lineno, ctx->section, ctx->key, ctx->value,
- formatted_msg);
+ ctx->conf, file, lineno, "%s:%d: [%s]%s%s%s%s: %s",
+ ctx->path, ctx->lineno, ctx->section, print_dot ? "." : "",
+ ctx->key, print_colon ? ": " : "", ctx->value, formatted_msg);
free(formatted_msg);
}