Handle rsyslog format tags

This commit is contained in:
Jamie Cameron
2009-06-16 21:06:12 +00:00
parent 5367f47660
commit 9464d7496e
3 changed files with 15 additions and 0 deletions

View 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.

View File

@@ -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);
}

View 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;
}