/usr/share/perl5/Log/Report/Dispatcher/File.pm is in liblog-report-perl 0.998-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # Copyrights 2007-2013 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.01.
use warnings;
use strict;
package Log::Report::Dispatcher::File;
use vars '$VERSION';
$VERSION = '0.998';
use base 'Log::Report::Dispatcher';
use Log::Report 'log-report', syntax => 'SHORT';
use IO::File ();
use Encode qw/find_encoding/;
sub init($)
{ my ($self, $args) = @_;
if(!$args->{charset})
{ my $lc = $ENV{LC_CTYPE} || $ENV{LC_ALL} || $ENV{LANG} || '';
my $cs = $lc =~ m/\.([\w-]+)/ ? $1 : '';
$args->{charset} = length $cs && find_encoding $cs ? $cs : undef;
}
$self->SUPER::init($args);
my $name = $self->name;
my $to = delete $args->{to}
or error __x"dispatcher {name} needs parameter 'to'", name => $name;
if(ref $to)
{ $self->{output} = $to;
trace "opened dispatcher $name to a ".ref($to);
}
else
{ $self->{filename} = $to;
my $binmode = $args->{replace} ? '>' : '>>';
my $f = $self->{output} = IO::File->new($to, $binmode)
or fault __x"cannot write log into {file} with {binmode}"
, binmode => $binmode, file => $to;
$f->autoflush;
trace "opened dispatcher $name to $to with $binmode";
}
$self;
}
sub close()
{ my $self = shift;
$self->SUPER::close or return;
$self->{output}->close if $self->{filename};
$self;
}
sub filename() {shift->{filename}}
sub log($$$)
{ my $self = shift;
$self->{output}->print($self->SUPER::translate(@_));
}
1;
|