ctl->tag = ctl->login = xgetlogin();
if (!ctl->tag)
ctl->tag = "<someone>";
-
- generate_syslog_header(ctl);
}
/* re-open; usually after failed connection */
{
/* note: we re-generate 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 default_priority = ctl->pri;
- int last_pri = default_priority;
char *buf = xmalloc(ctl->max_message_size + 2 + 2);
int pri;
int c;
} else
ctl->pri = default_priority;
- if (ctl->pri != last_pri) {
- generate_syslog_header(ctl);
- last_pri = ctl->pri;
- }
if (c != EOF && c != '\n')
c = getchar();
}
}
buf[i] = '\0';
- if (i > 0 || !ctl->skip_empty_lines)
+ if (i > 0 || !ctl->skip_empty_lines) {
+ generate_syslog_header(ctl);
write_output(ctl, buf);
+ }
if (c == '\n') /* discard line terminator */
c = getchar();
abort();
}
logger_open(&ctl);
- if (0 < argc)
+ if (0 < argc) {
+ generate_syslog_header(&ctl);
logger_command_line(&ctl, argv);
- else
+ } else
/* Note. --file <arg> reopens stdin making the below
* function to be used for file inputs. */
logger_stdin(&ctl);
+
logger_close(&ctl);
return EXIT_SUCCESS;
}