On Tue, Feb 23, 2016 at 07:23:34PM +0000, Sami Kerola wrote: > Earlier separate inputs got the same timestamp even when input arrival was > ensured to happen at different second. > > $ (echo foo; sleep 1.1; echo bar) | logger -t baz --no-act -s > <13>Feb 23 19:21:08 baz: foo > <13>Feb 23 19:21:08 baz: bar > > Addresses: http://bugs.debian.org/798239 > Signed-off-by: Sami Kerola <kerolasa@xxxxxx> > --- > misc-utils/logger.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/misc-utils/logger.c b/misc-utils/logger.c > index e439266..105426c 100644 > --- a/misc-utils/logger.c > +++ b/misc-utils/logger.c > @@ -949,6 +949,7 @@ static void logger_stdin(struct logger_ctl *ctl) > c = getchar(); > } > buf[i] = '\0'; > + generate_syslog_header(ctl); > > if (i > 0 || !ctl->skip_empty_lines) > write_output(ctl, buf); Not sure about this patch * it would be better to generate header if we really want to write the message (see condition with skip_empty_lines) * after priority change we will generated the header more than once * for the first message we generate header more than once (first time in logger_open() I have applied the patch below. Karel >From 7db029e54a4c0fdab43e8f645e4f91314747887c Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@xxxxxxxxxx> Date: Wed, 24 Feb 2016 10:40:08 +0100 Subject: [PATCH] logger: always update header when writing stdin line Addresses: http://bugs.debian.org/798239 Reported-by: Sami Kerola <kerolasa@xxxxxx> Signed-off-by: Karel Zak <kzak@xxxxxxxxxx> --- misc-utils/logger.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/misc-utils/logger.c b/misc-utils/logger.c index e439266..1e893a9 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -905,6 +905,11 @@ static void logger_command_line(const struct logger_ctl *ctl, char **argv) static void logger_stdin(struct logger_ctl *ctl) { + /* note: we re-generate the the syslog header for each log message to + * update header timestamps and to reflect possible priority changes. + * The initial header is generated by logger_open(). + */ + int has_header = 1; int default_priority = ctl->pri; int last_pri = default_priority; size_t max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr); @@ -935,7 +940,7 @@ static void logger_stdin(struct logger_ctl *ctl) ctl->pri = default_priority; if (ctl->pri != last_pri) { - generate_syslog_header(ctl); + has_header = 0; max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr); last_pri = ctl->pri; } @@ -950,8 +955,12 @@ static void logger_stdin(struct logger_ctl *ctl) } buf[i] = '\0'; - if (i > 0 || !ctl->skip_empty_lines) + if (i > 0 || !ctl->skip_empty_lines) { + if (!has_header) + generate_syslog_header(ctl); write_output(ctl, buf); + has_header = 0; + } if (c == '\n') /* discard line terminator */ c = getchar(); -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html