From 4daf27ca56a759db50c487e81067c6e4d426d79f Mon Sep 17 00:00:00 2001 From: Francesco Lavra Date: Wed, 2 Feb 2022 10:49:30 +0100 Subject: [PATCH] Klibs: syslog: use IMAGE_NAME environment variable as APP-NAME With this change, if the IMAGE_NAME environment variable is present it is used to populate the APP_NAME field in syslog messages, while the program name is used as a fallback. --- klib/syslog.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/klib/syslog.c b/klib/syslog.c index bc646893c..881a717ef 100644 --- a/klib/syslog.c +++ b/klib/syslog.c @@ -439,7 +439,10 @@ int init(status_handler complete) } if (syslog.server) { syslog_server_resolve(); - syslog.program = get(root, sym(program)); + tuple env = get_environment(); + syslog.program = get(env, sym(IMAGE_NAME)); + if (!syslog.program) + syslog.program = get(root, sym(program)); syslog.max_hdr_len = 1 + sizeof(__XSTRING(SYSLOG_PRIORITY)) + sizeof(SYSLOG_VERSION) + sizeof("YYYY-MM-ddThh:mm:ss.uuuuuuZ") + sizeof(syslog.local_ip) + buffer_length(syslog.program) + 7;