File Coverage

blib/lib/Apache/Voodoo/Debug.pm
Criterion Covered Total %
statement 34 94 36.1
branch 4 8 50.0
condition n/a
subroutine 4 23 17.3
pod 0 20 0.0
total 42 145 28.9


line stmt bran cond sub pod time code
1             package Apache::Voodoo::Debug;
2              
3             $VERSION = "3.0200";
4              
5 2     2   12 use strict;
  2         3  
  2         73  
6 2     2   12 use warnings;
  2         4  
  2         86  
7              
8 2     2   13 use Apache::Voodoo::Constants;
  2         5  
  2         2193  
9              
10             sub new {
11 3     3 0 8 my $class = shift;
12 3         5 my $conf = shift;
13              
14 3         9 my $self = {};
15 3         13 $self->{handlers} = [];
16              
17 3 50       116 unless (ref($conf->{'debug'}) eq "HASH") {
18             # old style config, so we'll go full monty for devel and silence for production.
19 3         23 $conf->{'debug'} = {
20             'FirePHP' => { all => 1 },
21             'Native' => { all => 1 }
22             };
23             }
24              
25 3         8 my @handlers;
26 3         5 foreach (keys %{$conf->{'debug'}}) {
  3         16  
27 6 50       28 if ($conf->{'debug'}->{$_}) {
28 6         15 my $package = 'Apache::Voodoo::Debug::'.$_;
29 6         16 my $file = $package.'.pm';
30              
31 6         30 $file =~ s/::/\//g;
32              
33 6         7584 require $file;
34 6         17 push(@{$self->{handlers}}, $package->new($conf->{'id'},$conf->{'debug'}->{$_}));
  6         78  
35              
36             }
37             }
38              
39 3         49 my $ac = Apache::Voodoo::Constants->new();
40 3 50       14 if ($ac->use_log4perl) {
41 3         1676 require Apache::Voodoo::Debug::Log4perl;
42 3         27 my $l4p = Apache::Voodoo::Debug::Log4perl->new($conf->{'id'},$ac->log4perl_conf);
43              
44 3 50       17 unless ($conf->{'debug'}->{'Log4perl'}) {
45             # Tomfoolery to deal with log4perl being a singlton.
46             # If the config file pulls in log4perl, we don't want to add the instance again,
47             # lest we end up with duplicated messages.
48 3         6 push(@{$self->{handlers}},$l4p);
  3         10  
49             }
50             }
51              
52 3         9 bless $self,$class;
53              
54 3         27 return $self;
55             }
56              
57 0     0 0   sub bootstrapped { my $self = shift; $_->bootstrapped(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
58 0     0 0   sub init { my $self = shift; $_->init(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
59 0     0 0   sub shutdown { my $self = shift; $_->shutdown(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
60              
61 0     0 0   sub debug { my $self = shift; $_->debug(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
62 0     0 0   sub info { my $self = shift; $_->info(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
63 0     0 0   sub warn { my $self = shift; $_->warn(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
64 0     0 0   sub error { my $self = shift; $_->error(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
65 0     0 0   sub exception { my $self = shift; $_->exception(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
66 0     0 0   sub trace { my $self = shift; $_->trace(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
67 0     0 0   sub table { my $self = shift; $_->table(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
68              
69 0     0 0   sub mark { my $self = shift; $_->mark(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
70 0     0 0   sub return_data { my $self = shift; $_->return_data(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
71 0     0 0   sub session_id { my $self = shift; $_->session_id(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
72 0     0 0   sub url { my $self = shift; $_->url(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
73 0     0 0   sub status { my $self = shift; $_->status(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
74 0     0 0   sub params { my $self = shift; $_->params(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
75 0     0 0   sub template_conf { my $self = shift; $_->template_conf(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
76 0     0 0   sub session { my $self = shift; $_->session(@_) foreach (@{$self->{'handlers'}}); }
  0            
  0            
77              
78             sub finalize {
79 0     0 0   my $self = shift;
80              
81 0           my @d;
82 0           foreach (@{$self->{handlers}}) {
  0            
83 0           push(@d,$_->finalize(@_));
84             }
85 0           return @d;
86             }
87              
88             1;
89              
90             ################################################################################
91             # Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org).
92             # All rights reserved.
93             #
94             # You may use and distribute Apache::Voodoo under the terms described in the
95             # LICENSE file include in this package. The summary is it's a legalese version
96             # of the Artistic License :)
97             #
98             ################################################################################