48 |
############################################################################### |
############################################################################### |
49 |
sub ::syslog { |
sub ::syslog { |
50 |
|
|
51 |
if($::CONF{'Debug'}) |
my $debug=$::CONF{'Debug'}; |
52 |
|
|
53 |
|
my $priority=shift; |
54 |
|
return if($priority eq 'debug' && !$debug); |
55 |
|
|
56 |
|
my $format=shift; |
57 |
|
my @args=@_; |
58 |
|
|
59 |
|
if($format eq '') |
60 |
|
{ |
61 |
|
my $txt=join("\t",@args); |
62 |
|
$format='%s'; |
63 |
|
@args=($txt); |
64 |
|
} |
65 |
|
|
66 |
|
my $facility=$::CONF{'SyslogFacility'} || $Meteor::Syslog::DEFAULT_FACILITY; |
67 |
|
|
68 |
|
if($debug || $facility eq 'none') |
69 |
{ |
{ |
|
my $priority=shift; |
|
|
my $format=shift; |
|
|
|
|
70 |
$format=~s/\%m/$!/g; |
$format=~s/\%m/$!/g; |
71 |
|
|
72 |
print STDERR "$::PGM($priority): "; |
my $time = ($::CONF{'LogTimeFormat'} eq 'unix') ? time : localtime(time); |
73 |
print STDERR sprintf($format,@_); |
|
74 |
|
print STDERR "$time\t$priority\t"; |
75 |
|
print STDERR sprintf($format,@args); |
76 |
print STDERR "\n" unless(substr($format,-1) eq "\n"); |
print STDERR "\n" unless(substr($format,-1) eq "\n"); |
77 |
|
|
78 |
return; |
return; |
79 |
} |
} |
|
else |
|
|
{ |
|
|
# No expensive syslog calls for debug! |
|
|
return if($_[0] eq 'debug'); |
|
|
} |
|
80 |
|
|
81 |
unless($Meteor::Syslog::_open) |
unless($Meteor::Syslog::_open) |
82 |
{ |
{ |
85 |
$Meteor::Syslog::_open=1; |
$Meteor::Syslog::_open=1; |
86 |
} |
} |
87 |
|
|
88 |
syslog(@_); |
syslog($priority,$format,@args); |
89 |
} |
} |
90 |
|
|
91 |
sub myWarn { |
sub myWarn { |