v01d commented on issue #3157: URL: https://github.com/apache/incubator-nuttx/issues/3157#issuecomment-812573159
If we knew that the "important" message is emitted only in log_writev I would simply ignore the other two and add a newline. @donghengqaz can we assume this? This way we can also drop the unneeded prefix. Otherwise I think that using an internal line buffer is the only solution if these calls will always be made separately to build the message. Related to this discussion is the fact that I think `syslog()` should probably handle the newline adding on its own, as per the opengroup specification suggests (last phrase): > The message body is generated from the message and following arguments in the same manner as if these were arguments to printf(), except that the additional conversion specification %m shall be recognized; it shall convert no arguments, shall cause the output of the error message string associated with the value of errno on entry to syslog(), and may be mixed with argument specifications of the "%n$" form. If a complete conversion specification with the m conversion specifier character is not just %m, the behavior is undefined. A trailing <newline> may be added if needed. Linux has this in its manpage: > The remaining arguments are a format, as in printf(3), and any arguments required by the format, except that the two-character sequence %m will be replaced by the error message string strerror(errno). The format string need not include a terminating newline character. And this is BSD: > The message is identical to a printf(3) format string, except that `%m' is replaced by the current error message. (As denoted by the global variable errno; see strerror(3).) A trailing newline is added if none is present. Newlines and other non-printable characters embedded in the message string are printed in an alternate format. This prevents someone from using non-printable characters to construct misleading log messages in an output file. Newlines are printed as "\n", tabs are printed as "\t". Other control characters are printed using a caret ("^") representation, for example "^M" for carriage return. I think we should: 1. make syslog append newline if not present in message 2. replace other newlines with a printable character 3. Remove all use of "\n" inside syslog calls This way we can avoid misuse of syslog() -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org