Log/Apache.pm untested

filter: Statementstmt 0.0% 0 / 52 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 88 CC 8 SCAR 31.3
CC
8
Cov
0%
write
42.0
BEGIN
12.0
BEGIN
2.0
CRAP 22.8
1 package Easy::Log::Apache;
2 use Easy::Log qw(:all);
3 use Easy::Log::Filter;
4 my $filter_file;
5 our $this_package;
6 BEGIN {
7 # this little but of cruft really sucks, but neither 'require' nor 'do' are bahaving as I would expect(akin to a c #include)
8 # require '/home/lengthe/cvs/adg/util/general/Log/Filter.pm';
9 #require Easy::Log::Filter;
10 #do Easy::Log::Filter;
11 $filter_file = ( __PACKAGE__ eq 'Easy::Log' ? __FILE__ : $INC{'Log/Easy.pm'} ) or die "Couldn't find location of Log/Easy.pm package";
12 $filter_file =~ s|Easy.pm|Easy/Filter.pm|;
13 #print STDERR "filter_file=$filter_file\n";
14 my $eval = 'package ' . __PACKAGE__ . ';';
15 # this is somewhat evil, but I need to do it to get filtering in THIS package, as well as packages that use this package
16 $eval .= '#' . `cat $filter_file`; # the '#' here comments out the first line of the filter package 'package Easy::Log::Filter;'
17 print STDERR $eval if $ENV{LOG_FILTER_DEBUG};
18 eval "{ $eval }";
19 $@ and die $@;
20 #die;
21 }
22 use strict;
23 our @ISA = qw( Easy::Log );
24 use Exporter;
25 our %EXPORT_TAGS = %Easy::Log::EXPORT_TAGS;
26 our @EXPORT_OK = @{$EXPORT_TAGS{'all'}};
27 our @EXPORT = ();
28 our $log = new Apache::Easy::Log;
29 our $plog = new Easy::Log;
30 $plog->log_file('STDERR');
31 sub write {
32 #die;
33 my $self = shift;
34 my @msg = @_;
35 my ($level, $_level, $log_level, $_log_level, $args) = $self->_check_level( \@msg );
36 $plog->write(DEBUG, '$args: ', $args );
37 my $n = exists $args->{n} ? $args->{n} : ($self->{n} || "\n");
38 my ( $status, $return);
39 {
40 local $args->{dont_actually_log} = 1;
41 local $args->{backstack} = 1;
42 $plog->write($dll, '$args: ', $args );
43 ( $status, $return ) = $self->SUPER::write($args, $level, @msg );
44 #$plog->write(DEBUG, '$status: ', $status );
45 #$plog->write(DEBUG, '$return: ', $return );
46 }
47 if ( $status ) {
48 $return .= $n;
49 if ( $ENV{GATEWAY_INTERFACE} and $args->{log_file} eq 'STDOUT' ) {
50 $return =~ s/\n/<BR>\n/mg;
51 my $s = '&nbsp;';
52 my $t = $s x 5;
53 $return =~ s/\ /$s/mg;
54 $return =~ s/\t/$t/mg;
55 }
56 my $fh = $self->fh( %$args, -level => $level, -message => $return );
57 unless ( $args->{dont_actually_log} ) {
58 print $fh $return;
59 }
60 }
61 #$plog->write($lll, '$status: ', $status );
62 #$plog->write($lll, '$return: ', $return );
63 return wantarray ? ( $status, $return ) : $status ;
64 }
65 # sub _actually_log {
66 # # this is where we would probably normally pass this log message off to apache unless the log_file is STDOUT
67 # # then again maybe not :-)
68 #}
69 1;