Skip to content
Snippets Groups Projects
Commit 7d4ae7dc authored by George Joseph's avatar George Joseph
Browse files

logger.c: Automatically add a newline to formats that don't have one

Scope tracing allows you to not specify a format string or variable,
in which case it just prints the indent, file, function, and line
number.  The trace output automatically adds a newline to the end
in this case.  If you also have debugging turned on for the module,
a debug message is also printed but the standard log functionality
which prints it doesn't add the newline so you have messages
that don't break correctly.

 * format_log_message_ap(), which is the common log
   message formatter for all channels, now adds a
   newline to the end of format strings that don't
   already have a newline.

ASTERISK-29209
Reported by: Alexander Traud

Change-Id: I994a7df27f88df343b7d19f3e81a4b562d9d41da
parent 0b109958
No related branches found
No related tags found
3 merge requests!138Merge branch asterisk-20.3.0 into devel properly,!123Merge asterisk '20.3.0' into devel,!118Draft: manager: AOC-S support for AOCMessage
...@@ -1672,6 +1672,11 @@ static struct logmsg * __attribute__((format(printf, 7, 0))) format_log_message_ ...@@ -1672,6 +1672,11 @@ static struct logmsg * __attribute__((format(printf, 7, 0))) format_log_message_
return NULL; return NULL;
} }
/* Automatically add a newline to format strings that don't have one */
if (!ast_ends_with(ast_str_buffer(buf), "\n")) {
ast_str_append(&buf, 0, "\n");
}
/* Create a new logging message */ /* Create a new logging message */
if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128))) { if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128))) {
return NULL; return NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment