From 6cc21f187e939939b72d5f6aaa3cb61a99f890dd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 18 Mar 2009 16:27:02 -0700 Subject: [PATCH] vlog: Trim trailing new-lines from log messages. Sometimes a message passed into a vlog function will have a trailing new-line due to carelessness. Tolerate this situation by just trimming them off in format_log_message(). --- lib/vlog.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vlog.c b/lib/vlog.c index 08f1e4eb..fc5f9a10 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -522,9 +522,14 @@ format_log_message(enum vlog_module module, enum vlog_level level, ds_put_strftime(s, tmp, NULL); break; case 'm': + /* Format user-supplied log message and trim trailing new-lines. */ + length = s->length; va_copy(args, args_); ds_put_format_valist(s, message, args); va_end(args); + while (s->length > length && s->string[s->length - 1] == '\n') { + s->length--; + } break; case 'N': ds_put_format(s, "%u", msg_num); -- 2.30.2