Handle rsyslog format tags
authorJamie Cameron <jcameron@webmin.com>
Tue, 16 Jun 2009 21:06:12 +0000 (21:06 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 16 Jun 2009 21:06:12 +0000 (21:06 +0000)
syslog/CHANGELOG
syslog/save_log.cgi
syslog/syslog-lib.pl

index bbaac8e..d6baccd 100644 (file)
@@ -12,3 +12,5 @@ On Debian systems, use a syslog restart to tell it to re-open log files, as a HU
 On Fedora 8, use rsyslog by default instead of syslog.
 ---- Changes since 1.430 ----
 Added support for rsyslogd, as seen by default on Debian 5.0.
+---- Changes since 1.480 ----
+Rsyslog format tags in the config file are now recogized and preserved, rather than being included in the log filename.
index bf1d097..5d78e7d 100755 (executable)
@@ -209,6 +209,7 @@ else {
        else {
                &can_edit_log($log) || &error($text{'save_ecannot4'});
                $old = $conf->[$in{'idx'}];
+               $log->{'format'} = $old->{'format'};    # Copy for now
                &can_edit_log($old) || &error($text{'save_ecannot5'});
                &update_log($old, $log);
                }
index 4a7bb83..020840c 100644 (file)
@@ -35,6 +35,9 @@ while($line = <CONF>) {
        if ($line =~ /^\$(\S+)\s*(\S*)/) {
                # rsyslog special directive - ignored for now
                }
+       elsif ($line =~ /^if\s+/) {
+               # rsyslog if statement .. ignored too
+               }
        elsif ($line =~ /^(#*)\s*([^#\s]+\.\S+)\s+(\S+)$/ ||
               $line =~ /^(#*)\s*([^#\s]+\.\S+)\s+(\|.*)$/) {
                # Regular log destination
@@ -69,6 +72,11 @@ while($line = <CONF>) {
                $log->{'index'} = scalar(@rv);
                $log->{'section'} = $tag;
                $tag->{'eline'} = $lnum;
+               if ($log->{'file'} =~ s/^(\/\S+);(\S+)$/$1/ ||
+                    $log->{'pipe'} =~ s/^(\/\S+);(\S+)$/$1/) {
+                       # rsyslog file format
+                       $log->{'format'} = $2;
+                       }
                push(@rv, $log);
                }
        elsif ($line =~ /^(#?)!(\S+)$/) {
@@ -152,6 +160,10 @@ elsif ($_[0]->{'socket'}) {
 else {
        $d = '*';
        }
+if ($_[0]->{'format'}) {
+       # Add rsyslog format
+       $d .= ";".$_[0]->{'format'};
+       }
 return ($_[0]->{'active'} ? "" : "#").join(";", @{$_[0]->{'sel'}})."\t".$d;
 }