1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 23:51:28 +03:00

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2012-11-26 16:39:46 +01:00
parent 41a79f1062
commit e429981ba4

View File

@ -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" : "",