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 $priority=shift; |
my $txt=join("\t",@args); |
|
my $format=shift; |
|
62 |
|
|
63 |
|
$format='%s'; |
64 |
|
@args=($txt); |
65 |
|
} |
66 |
|
|
67 |
|
my $facility=$::CONF{'SyslogFacility'} || $Meteor::Syslog::DEFAULT_FACILITY; |
68 |
|
|
69 |
|
if($debug || $facility eq 'none') |
70 |
|
{ |
71 |
$format=~s/\%m/$!/g; |
$format=~s/\%m/$!/g; |
72 |
|
|
73 |
print STDERR "$::PGM($priority): "; |
my $time=time; |
74 |
|
|
75 |
|
print STDERR "$time\t$::PGM($priority): "; |
76 |
print STDERR sprintf($format,@_); |
print STDERR sprintf($format,@_); |
77 |
print STDERR "\n" unless(substr($format,-1) eq "\n"); |
print STDERR "\n" unless(substr($format,-1) eq "\n"); |
78 |
|
|
79 |
return; |
return; |
80 |
} |
} |
|
else |
|
|
{ |
|
|
# No expensive syslog calls for debug! |
|
|
return if($_[0] eq 'debug'); |
|
|
} |
|
81 |
|
|
82 |
unless($Meteor::Syslog::_open) |
unless($Meteor::Syslog::_open) |
83 |
{ |
{ |
86 |
$Meteor::Syslog::_open=1; |
$Meteor::Syslog::_open=1; |
87 |
} |
} |
88 |
|
|
89 |
syslog(@_); |
syslog($priority,$format,@args); |
90 |
} |
} |
91 |
|
|
92 |
sub myWarn { |
sub myWarn { |