From: Zbigniew Jędrzejewski-Szmek Date: Mon, 26 Nov 2012 15:39:46 +0000 (+0100) Subject: share/log: skip file/line/func info if empty X-Git-Tag: v198~479 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=e429981ba45894fe51d93956278badb61311bb99 share/log: skip file/line/func info if empty The new microhttpd logger doesn't know this information. It is better to log nothing than fake values. --- diff --git a/src/shared/log.c b/src/shared/log.c index b39b5acb5..293c261f9 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -448,16 +448,22 @@ static int log_do_header(char *header, size_t size, snprintf(header, size, "PRIORITY=%i\n" "SYSLOG_FACILITY=%i\n" - "CODE_FILE=%s\n" - "CODE_LINE=%i\n" - "CODE_FUNCTION=%s\n" + "%s%.*s%s" + "%s%.*i%s" + "%s%.*s%s" "%s%.*s%s" "SYSLOG_IDENTIFIER=%s\n", LOG_PRI(level), LOG_FAC(level), - file, - line, - func, + file ? "CODE_FILE=" : "", + file ? LINE_MAX : 0, file, /* %.0s means no output */ + file ? "\n" : "", + line ? "CODE_LINE=" : "", + line ? 1 : 0, line, /* %.0d means no output too, special case for 0 */ + line ? "\n" : "", + func ? "CODE_FUNCTION=" : "", + func ? LINE_MAX : 0, func, + func ? "\n" : "", object ? object_name : "", object ? LINE_MAX : 0, object, /* %.0s means no output */ object ? "\n" : "",