From cd1ab6120870fd140e7a9be8b59780deff770903 Mon Sep 17 00:00:00 2001 From: archie Date: Sat, 5 Jan 2002 07:34:52 +0000 Subject: Add a new flag '-c' to disable repeated line compression when the output is a pipe to another program, or, if specified twice, in all cases. PR: bin/32420 --- usr.sbin/syslogd/syslogd.8 | 6 ++++++ usr.sbin/syslogd/syslogd.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'usr.sbin/syslogd') diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index cfa2a51..7807a6b 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -156,6 +156,12 @@ option is also specified. Specify one specific IP address or hostname to bind to. If a hostname is specified, the IPv4 or IPv6 address which corresponds to it is used. +.It Fl c +Disable the compression of repeated instances of the same line +into a single line of the form +.Dq last message repeated N times +when the output is a pipe to another program. +If specified twice, disable this compression in all cases. .It Fl d Put .Nm diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 0cfa84c..9a534e3 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -274,6 +274,7 @@ int family = PF_INET; /* protocol family (IPv4 only) */ #endif int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */ int use_bootfile = 0; /* log entire bootfile for every kern msg */ +int no_compress = 0; /* don't compress messages (1=pipes, 2=all) */ char bootfile[MAXLINE+1]; /* booted kernel file */ @@ -334,7 +335,7 @@ main(argc, argv) socklen_t len; bindhostname = NULL; - while ((ch = getopt(argc, argv, "46Aa:b:df:kl:m:nop:P:suv")) != -1) + while ((ch = getopt(argc, argv, "46Aa:b:cdf:kl:m:nop:P:suv")) != -1) switch (ch) { case '4': family = PF_INET; @@ -354,6 +355,9 @@ main(argc, argv) case 'b': bindhostname = optarg; break; + case 'c': + no_compress++; + break; case 'd': /* debug */ Debug++; break; @@ -865,7 +869,8 @@ logmsg(pri, msg, from, flags) /* * suppress duplicate lines to this file */ - if ((flags & MARK) == 0 && msglen == f->f_prevlen && + if (no_compress - (f->f_type != F_PIPE) < 1 && + (flags & MARK) == 0 && msglen == f->f_prevlen && !strcmp(msg, f->f_prevline) && !strcasecmp(from, f->f_prevhost)) { (void)strlcpy(f->f_lasttime, timestamp, 16); -- cgit v1.1