| 1 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package Log::Log4perl::Logger; | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 54 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 54 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 54 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 54 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 54 | ▶ | use Log::Log4perl::Level; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 54 | ▶ | use Log::Log4perl::Layout; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 54 | ▶ | use Log::Log4perl::Appender; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 54 | ▶ | use Log::Log4perl::Appender::String; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 54 | ▶ | use Log::Log4perl::Filter; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 54 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 54 | $Carp::Internal{"Log::Log4perl"}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 54 | $Carp::Internal{"Log::Log4perl::Logger"}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 54 | ▶ | use constant _INTERNAL_DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Initialization | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 54 | our $ROOT_LOGGER; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 54 | our $LOGGERS_BY_NAME = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 54 | our %APPENDER_BY_NAME = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 54 | our $INITIALIZED = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 54 | our $NON_INIT_WARNED; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 54 | our $DIE_DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 54 | our $DIE_DEBUG_BUFFER = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | # Define the default appender that's used for formatting | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # warn/die/croak etc. messages. | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 54 | our $STRING_APP_NAME = "_l4p_warn"; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 54 | our $STRING_APP = Log::Log4perl::Appender->new( | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | "Log::Log4perl::Appender::String", | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | name => $STRING_APP_NAME); | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 54 | $STRING_APP->layout(Log::Log4perl::Layout::PatternLayout->new("%m")); | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 54 | our $STRING_APP_CODEREF = generate_coderef([[$STRING_APP_NAME, $STRING_APP]]); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 54 | __PACKAGE__->reset(); | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ########################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub warning_render { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warning_render: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ########################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my($logger, @message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $STRING_APP->string(""); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $STRING_APP_CODEREF->($logger, | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | @message, | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Log::Log4perl::Level::to_level($ALL)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $STRING_APP->string(); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 55 | ▶ | sub cleanup { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # warn "Logger cleanup"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Nuke all convenience loggers to avoid them causing cleanup to | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # be delayed until global destruction. Problem is that something like | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # *{"DEBUG"} = sub { $logger->debug }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # ties up a reference to $logger until global destruction, so we | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # need to clean up all :easy shortcuts, hence freeing the last | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # logger references, to then rely on the garbage collector for cleaning | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # up the loggers. | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 55 | Log::Log4perl->easy_closure_global_cleanup(); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Delete all loggers | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 55 | $LOGGERS_BY_NAME = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Delete the root logger | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 55 | undef $ROOT_LOGGER; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Delete all appenders | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 55 | %APPENDER_BY_NAME = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 55 | undef $INITIALIZED; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 133 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 133 | ▶ | CORE::warn "Destroying logger $_[0] ($_[0]->{category})" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | if $Log::Log4perl::CHATTY_DESTROY_METHODS; | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 243 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 243 | $ROOT_LOGGER = __PACKAGE__->_new("", $OFF); | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | # $LOGGERS_BY_NAME = {}; #leave this alone, it's used by | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #reset_all_output_methods when | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | #the config changes | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 243 | %APPENDER_BY_NAME = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 243 | undef $INITIALIZED; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 243 | undef $NON_INIT_WARNED; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 243 | Log::Log4perl::Appender::reset(); | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #clear out all the existing appenders | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 243 | foreach my $logger (values %$LOGGERS_BY_NAME){ | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 431 | $logger->{appender_names} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | #this next bit deals with an init_and_watch case where a category | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | #is deleted from the config file, we need to zero out the existing | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | #loggers so ones not in the config file not continue with their old | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | #behavior --kg | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 431 | ▶ | next if $logger eq $ROOT_LOGGER; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 188 | $logger->{level} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 188 | $logger->level(); #set it from the hierarchy | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # Clear all filters | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 243 | Log::Log4perl::Filter::reset(); | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 445 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 445 | my($class, $category, $level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 445 | print("_new: $class/$category/", defined $level ? $level : "undef", | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | "\n") if _INTERNAL_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 445 | ▶ | die "usage: __PACKAGE__->_new(category)" unless | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | defined $category; | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 445 | $category =~ s/::/./g; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # Have we created it previously? | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 445 | ▶ | if(exists $LOGGERS_BY_NAME->{$category}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 310 | print "_new: exists already\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 310 | return $LOGGERS_BY_NAME->{$category}; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 135 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | category => $category, | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | num_appenders => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | additivity => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | level => $level, | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | layout => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 135 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 135 | ▶ | $level ||= $self->level(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$level ||= $self->level
MC/DC100%2/2
$level ||= $self->level
$level
$self->level
Truth table100%3/3
A ||= B
A= $levelB= $self->level
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # Save it in global structure | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 135 | $LOGGERS_BY_NAME->{$category} = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 135 | $self->set_output_methods; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 135 | print("Created logger $self ($category)\n") if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 135 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | sub category { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
category: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | return $self->{ category }; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 206 | ▶ | sub reset_all_output_methods { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_all_output_methods: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 206 | print "reset_all_output_methods: \n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 206 | foreach my $loggername ( keys %$LOGGERS_BY_NAME){ | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 555 | $LOGGERS_BY_NAME->{$loggername}->set_output_methods; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 206 | $ROOT_LOGGER->set_output_methods; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 905 | ▶ | sub set_output_methods { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_output_methods: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # Here's a big performance increase. Instead of having the logger | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # calculate whether to log and whom to log to every time log() is called, | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # we calculate it once when the logger is created, and recalculate | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # it if the config information ever changes. | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 905 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 905 | my (@appenders, %seen); | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 905 | my ($level) = $self->level(); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 905 | print "set_output_methods: $self->{category}/$level\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | #collect the appenders in effect for this category | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 905 | ▶ | for(my $logger = $self; $logger; $logger = parent_logger($logger)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1415 | foreach my $appender_name (@{$logger->{appender_names}}){ | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | #only one message per appender, (configurable) | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 774 | ▶ | next if $seen{$appender_name} ++ && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$seen{$appender_name}++ and $Log::Log4perl::one_message_per_appender
MC/DC100%2/2
$seen{$appender_name}++ and $Log::Log4perl::one_message_per_appender
$seen{$appender_name}++
$Log::Log4perl::one_message_per_appender
Truth table100%3/3
A and B
A= $seen{$appender_name}++B= $Log::Log4perl::one_message_per_appender
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $Log::Log4perl::one_message_per_appender; | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | push (@appenders, | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | [$appender_name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 768 | $APPENDER_BY_NAME{$appender_name}, | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | ] | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1415 | ▶ | last unless $logger->{additivity}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | #make a no-op coderef for inactive levels | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 905 | my $noop = generate_noop_coderef(); | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | #make a coderef | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 905 | ▶ | my $coderef = (! @appenders ? $noop : &generate_coderef(\@appenders)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 905 | my %priority = %Log::Log4perl::Level::PRIORITY; #convenience and cvs | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # changed to >= from <= as level ints were reversed | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 905 | foreach my $levelname (keys %priority){ | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 8294 | ▶ | if (Log::Log4perl::Level::isGreaterOrEqual($level, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $priority{$levelname} | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 3877 | print " ($priority{$levelname} <= $level)\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | if _INTERNAL_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3877 | $self->{$levelname} = $coderef; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3877 | $self->{"is_$levelname"} = generate_is_xxx_coderef("1"); | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3877 | print "Setting is_$levelname to 1\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4417 | print " ($priority{$levelname} > $level)\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4417 | $self->{$levelname} = $noop; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4417 | $self->{"is_$levelname"} = generate_is_xxx_coderef("0"); | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 4417 | print "Setting is_$levelname to 0\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | print(" Setting [$self] $self->{category}.$levelname to ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 8294 | ($self->{$levelname} == $noop ? "NOOP" : | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | ("Coderef [$coderef]: " . scalar @appenders . " appenders")), | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | "\n") if _INTERNAL_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 640 | ▶ | sub generate_coderef { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_coderef: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 640 | my $appenders = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 640 | print "generate_coderef: ", scalar @$appenders, | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | " appenders\n" if _INTERNAL_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 640 | my $watch_check_code = generate_watch_code("logger", 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 330 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 330 | my $logger = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 330 | my $level = pop; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 330 | my $message; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 330 | my $appenders_fired = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Evaluate all parameters that need to be evaluated. Two kinds: | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # (1) It's a hash like { filter => "filtername", | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # value => "value" } | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # => filtername(value) | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # (2) It's a code ref | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # => coderef() | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 330 | $message = [map { ref $_ eq "HASH" && | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | exists $_->{filter} && | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ref $_->{filter} eq 'CODE' ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 370 | ▶ | $_->{filter}->($_->{value}) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
ref $_ eq "HASH" and exists $_->{"filter"} and ref $_->{"filter"} eq "CODE"
ref $_ eq "HASH" and exists $_->{"filter"}
MC/DC66%2/3
ref $_ eq "HASH" and exists $_->{"filter"} and ref $_->{"filter"} eq "CODE"
ref $_ eq "HASH"
exists $_->{"filter"}
ref $_->{"filter"} eq "CODE"
Truth table75%3/4
A and B and C
A= ref $_ eq "HASH"B= exists $_->{"filter"}C= ref $_->{"filter"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ref $_ eq "CODE" ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | $_->() : $_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } @_]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 330 | print("coderef: $logger->{category}\n") if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 330 | ▶ | if(defined $Log::Log4perl::Config::WATCHER) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | ▶ | return unless $watch_check_code->($logger, @_, $level); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 329 | foreach my $a (@$appenders) { #note the closure here | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 380 | my ($appender_name, $appender) = @$a; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 380 | print(" Sending message '<$message->[0]>' ($level) " . | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | "to $appender_name\n") if _INTERNAL_DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | $appender->log( | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | #these get passed through to Log::Dispatch | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | { name => $appender_name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | level => $Log::Log4perl::Level::L4P_TO_LD{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | $level}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | #these we need | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | $logger->{category}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 380 | ▶ | $level, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ) and $appenders_fired++; | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # Only counting it if it returns a true value. Otherwise | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # the appender threshold might have suppressed it after all. | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } #end foreach appenders | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 329 | return $appenders_fired; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 640 | }; #end coderef | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 905 | ▶ | sub generate_noop_coderef { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_noop_coderef: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 905 | my $watch_delay_code; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # This might seem crazy at first, but even in a Log4perl noop, we | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # need to check if the configuration changed in a init_and_watch | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # situation. Why? Say, an application is running in a loop that | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # constantly tries to issue debug() messages, but they're suppressed by | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # the current Log4perl configuration. If debug() (which is a noop | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # here) wasn't watching the configuration for changes, it would never | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # catch the case where someone bumps up the log level and expects | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # the application to pick it up and start logging debug() statements. | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 905 | my $watch_check_code = generate_watch_code("logger", 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 905 | my $coderef; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 905 | ▶ | if(defined $Log::Log4perl::Config::WATCHER) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 21 | $coderef = $watch_check_code; | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 884 | ▶ | $coderef = sub { undef }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 905 | return $coderef; | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 8294 | ▶ | sub generate_is_xxx_coderef { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_is_xxx_coderef: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 8294 | my($return_token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 8294 | return generate_watch_code("checker", $return_token); | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 9839 | ▶ | sub generate_watch_code { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_watch_code: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 9839 | my($type, $return_token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 9839 | print "generate_watch_code:\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # No watcher configured, return a no-op as watch code. | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 9839 | ▶ | if(! defined $Log::Log4perl::Config::WATCHER) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 9636 | ▶ | return sub { $return_token }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 203 | my $cond = generate_watch_conditional(); | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 41 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 41 | print "exe_watch_code:\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 41 | if(_INTERNAL_DEBUG) { | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | print "Next check: ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | "$Log::Log4perl::Config::Watch::NEXT_CHECK_TIME ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | " Now: ", time(), " Mod: ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | (stat($Log::Log4perl::Config::WATCHER->file()))[9], | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 41 | ▶ | if( $cond->() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | my $init_permitted = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | ▶ | if(exists $Log::Log4perl::Config::OPTS->{ preinit_callback } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | print "Calling preinit_callback\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | $init_permitted = | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $Log::Log4perl::Config::OPTS->{ preinit_callback }->( | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | Log::Log4perl::Config->watcher()->file() ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | print "Callback returned $init_permitted\n" if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | ▶ | if( $init_permitted ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | Log::Log4perl->init_and_watch(); | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # It was time to reinit, but init wasn't permitted. | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # Return true, so that the logger continues as if | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # it wasn't time to reinit. | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | my $logger = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | my $level = pop; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | # Forward call to new configuration | ||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | ▶ | if($type eq "checker") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | return $logger->$level(); | |||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } elsif( $type eq "logger") { | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 2 | my $methodname = lc($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # Bump up the caller level by three, since | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # we've artificially introduced additional levels. | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 2 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | $Log::Log4perl::caller_depth + 3; | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # Get a new logger for the same category (the old | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # logger might be obsolete because of the re-init) | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | $logger = Log::Log4perl::get_logger( $logger->{category} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | $logger->$methodname(@_); # send the message | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | # to the new configuration | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | return undef; # Return false, so the logger finishes | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | # prematurely and doesn't log the same | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # message again. | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | die "internal error: unknown type"; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 38 | if(_INTERNAL_DEBUG) { | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | print "Conditional returned false\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 38 | return $return_token; | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 203 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 203 | ▶ | sub generate_watch_conditional { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate_watch_conditional: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 203 | ▶ | if(defined $Log::Log4perl::Config::Watch::SIGNAL_CAUGHT) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # In this mode, we just check for the variable indicating | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # that the signal has been caught | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 16 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 16 | return $Log::Log4perl::Config::Watch::SIGNAL_CAUGHT; | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | 110 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 25 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 25 | ▶ | ( time() > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME and | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
time > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME && $Log::Log4perl::Config::WATCHER->change_detected
MC/DC100%2/2
time > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME && $Log::Log4perl::Config::WATCHER->change_detected
time > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIME
$Log::Log4perl::Config::WATCHER->change_detected
Truth table100%3/3
A && B
A= time > $Log::Log4perl::Config::Watch::NEXT_CHECK_TIMEB= $Log::Log4perl::Config::WATCHER->change_detected
| |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | $Log::Log4perl::Config::WATCHER->change_detected() ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 93 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1650 | ▶ | sub parent_string { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent_string: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1650 | my($string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1650 | ▶ | if($string eq "") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | return undef; # root doesn't have a parent. | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1650 | my @components = split /\./, $string; | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 1650 | ▶ | if(@components == 1) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 858 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 792 | pop @components; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 792 | return join('.', @components); | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1378 | ▶ | sub level { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
level: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1378 | my($self, $level, $dont_reset_all) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # 'Set' function | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 1378 | ▶ | if(defined $level) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 199 | ▶ | croak "invalid level '$level'" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | unless Log::Log4perl::Level::is_valid($level); | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 199 | ▶ | if ($level =~ /\D/){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 3 | $level = Log::Log4perl::Level::to_priority($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 199 | $self->{level} = $level; | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 199 | ▶ | &reset_all_output_methods | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | unless $dont_reset_all; #keep us from getting overworked | ||||||||||||||||||||||||||||||||||||||||||||||
| 482 | #if it's the config file calling us | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 199 | return $level; | |||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # 'Get' function | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1179 | ▶ | if(defined $self->{level}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 652 | return $self->{level}; | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 527 | ▶ | for(my $logger = $self; $logger; $logger = parent_logger($logger)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # Does the current logger have the level defined? | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1150 | ▶ | if($logger->{category} eq "") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # It's the root logger | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 470 | return $ROOT_LOGGER->{level}; | |||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 680 | ▶ | if(defined $LOGGERS_BY_NAME->{$logger->{category}}->{level}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 57 | return $LOGGERS_BY_NAME->{$logger->{category}}->{level}; | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # We should never get here because at least the root logger should | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # have a level defined | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | die "We should never get here."; | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1991 | ▶ | sub parent_logger { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent_logger: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # Get the parent of the current logger or undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 1991 | my($logger) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # Is it the root logger? | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 1991 | ▶ | if($logger->{category} eq "") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # Root has no parent | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 858 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # Go to the next defined (!) parent | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 1133 | my $parent_class = parent_string($logger->{category}); | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1133 | ▶ | while($parent_class ne "" and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$parent_class ne "" and not exists $Log::Log4perl::Logger::LOGGERS_BY_NAME->{$parent_class}
MC/DC100%2/2
$parent_class ne "" and not exists $Log::Log4perl::Logger::LOGGERS_BY_NAME->{$parent_class}
$parent_class ne ""
not exists $Log::Log4perl::Logger::LOGGERS_BY_NAME->{$parent_class}
Truth table100%3/3
A and not(B)
A= $parent_class ne ""B= not exists $Log::Log4perl::Logger::LOGGERS_BY_NAME->{$parent_class}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | ! exists $LOGGERS_BY_NAME->{$parent_class}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 517 | $parent_class = parent_string($parent_class); | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | 517 | $logger = $LOGGERS_BY_NAME->{$parent_class}; | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1133 | ▶ | if($parent_class eq "") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 858 | $logger = $ROOT_LOGGER; | |||||||||||||||||||||||||||||||||||||||||||||
| 534 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 275 | $logger = $LOGGERS_BY_NAME->{$parent_class}; | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1133 | return $logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | sub get_root_logger { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_root_logger: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return $ROOT_LOGGER; | |||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 6 | ▶ | sub additivity { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
additivity: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 6 | my($self, $onoff, $no_reinit) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 6 | ▶ | if(defined $onoff) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 6 | $self->{additivity} = $onoff; | |||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 6 | ▶ | if( ! $no_reinit ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | $self->set_output_methods(); | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 6 | return $self->{additivity}; | |||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 339 | ▶ | sub get_logger { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_logger: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 339 | my($class, $category) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 339 | ▶ | unless(defined $ROOT_LOGGER) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | Carp::confess "Internal error: Root Logger not initialized."; | |||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 338 | ▶ | return $ROOT_LOGGER if $category eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 202 | my $logger = $class->_new($category); | |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 202 | return $logger; | |||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 177 | ▶ | sub add_appender { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_appender: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 177 | my($self, $appender, $dont_reset_all) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # We take this as an indicator that we're initialized. | ||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 177 | $INITIALIZED = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 177 | my $appender_name = $appender->name(); | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 177 | $self->{num_appenders}++; #should this be inside the unless? | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # Add newly created appender to the end of the appender array | ||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 177 | ▶ | unless (grep{$_ eq $appender_name} @{$self->{appender_names}}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 176 | $self->{appender_names} = [sort @{$self->{appender_names}}, | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | $appender_name]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 177 | $APPENDER_BY_NAME{$appender_name} = $appender; | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 177 | ▶ | reset_all_output_methods | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | unless $dont_reset_all; # keep us from getting overworked | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # if it's the config file calling us | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # For chaining calls ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 177 | return $appender; | |||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 10 | ▶ | sub remove_appender { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_appender: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 10 | my($self, $appender_name, $dont_reset_all, $sloppy) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 10 | my %appender_names = map { $_ => 1 } @{$self->{appender_names}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 10 | ▶ | if(!exists $appender_names{$appender_name}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 6 | ▶ | die "No such appender: $appender_name" unless $sloppy; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 6 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 4 | delete $appender_names{$appender_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | 4 | $self->{num_appenders}--; | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | 4 | $self->{appender_names} = [sort keys %appender_names]; | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 4 | ▶ | &reset_all_output_methods | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | unless $dont_reset_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | sub eradicate_appender { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eradicate_appender: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # If someone calls Logger->... and not Logger::... | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | ▶ | shift if $_[0] eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 1 | my($appender_name, $dont_reset_all) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | return 0 unless exists | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | ▶ | $APPENDER_BY_NAME{$appender_name}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # Remove the given appender from all loggers | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # and delete all references to it, causing | ||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # its DESTROY method to be called. | ||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | foreach my $logger (values %$LOGGERS_BY_NAME){ | |||||||||||||||||||||||||||||||||||||||||||||
| 642 | 3 | $logger->remove_appender($appender_name, 0, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # Also remove it from the root logger | ||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | $ROOT_LOGGER->remove_appender($appender_name, 0, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | delete $APPENDER_BY_NAME{$appender_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | ▶ | &reset_all_output_methods | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | unless $dont_reset_all; | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | sub has_appenders { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_appenders: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 657 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | return $self->{num_appenders}; | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||
| 663 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 11 | ▶ | sub log { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: called CC=6 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # external api | ||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 11 | my ($self, $priority, @messages) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 11 | ▶ | confess("log: No priority given!") unless defined($priority); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # Just in case of 'init_and_watch' -- see Changes 0.21 | ||||||||||||||||||||||||||||||||||||||||||||||
| 672 | $_[0] = $LOGGERS_BY_NAME->{$_[0]->{category}} if | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 11 | ▶ | defined $Log::Log4perl::Config::WATCHER; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 11 | ▶ | init_warn() unless $INITIALIZED or $NON_INIT_WARNED; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Log::Log4perl::Logger::INITIALIZED or $Log::Log4perl::Logger::NON_INIT_WARNED
MC/DC0%0/2
$Log::Log4perl::Logger::INITIALIZED or $Log::Log4perl::Logger::NON_INIT_WARNED
$Log::Log4perl::Logger::INITIALIZED
$Log::Log4perl::Logger::NON_INIT_WARNED
Truth table33%1/3
A or B
A= $Log::Log4perl::Logger::INITIALIZEDB= $Log::Log4perl::Logger::NON_INIT_WARNED
| |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 11 | ▶ | croak "priority $priority isn't numeric" if ($priority =~ /\D/); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 11 | my $which = Log::Log4perl::Level::to_level($priority); | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 11 | $self->{$which}->($self, @messages, | |||||||||||||||||||||||||||||||||||||||||||||
| 682 | Log::Log4perl::Level::to_level($priority)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||
| 685 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # create_custom_level | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # creates a custom level | ||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # in theory, could be used to create the default ones | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 33 | ▶ | sub create_custom_level { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_custom_level: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 33 | ▶ | my $level = shift || die("create_custom_level: " . | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || die('create_custom_level: forgot to pass in a level string!')
MC/DC0%0/1
shift() || die('create_custom_level: forgot to pass in a level string!')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 694 | "forgot to pass in a level string!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 33 | ▶ | my $after = shift || die("create_custom_level: " . | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || die('create_custom_level: forgot to pass in a level after which to place the new level!')
MC/DC0%0/1
shift() || die('create_custom_level: forgot to pass in a level after which to place the new level!')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | "forgot to pass in a level after which to " . | ||||||||||||||||||||||||||||||||||||||||||||||
| 697 | "place the new level!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 33 | my $syslog_equiv = shift; # can be undef | |||||||||||||||||||||||||||||||||||||||||||||
| 699 | 33 | my $log_dispatch_level = shift; # optional | |||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | ## only let users create custom levels before initialization | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 33 | ▶ | die("create_custom_level must be called before init or " . | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 704 | "first get_logger() call") if ($INITIALIZED); | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 32 | my %PRIORITY = %Log::Log4perl::Level::PRIORITY; #convenience | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | die("create_custom_level: no such level \"$after\"! Use one of: ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 32 | ▶ | join(", ", sort keys %PRIORITY)) unless $PRIORITY{$after}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||
| 711 | # figure out new int value by AFTER + (AFTER+ 1) / 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 32 | my $next_prio = Log::Log4perl::Level::get_lower_level($PRIORITY{$after}, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 714 | 32 | my $cust_prio = int(($PRIORITY{$after} + $next_prio) / 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | die(qq{create_custom_level: Calculated level of $cust_prio already exists! | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | This should only happen if you've made some insane number of custom | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | levels (like 15 one after another) | ||||||||||||||||||||||||||||||||||||||||||||||
| 719 | You can usually fix this by re-arranging your code from: | ||||||||||||||||||||||||||||||||||||||||||||||
| 720 | create_custom_level("cust1", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | create_custom_level("cust2", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | create_custom_level("cust3", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 723 | create_custom_level("cust4", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | create_custom_level("cust5", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | into: | ||||||||||||||||||||||||||||||||||||||||||||||
| 726 | create_custom_level("cust3", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 727 | create_custom_level("cust5", X); | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | create_custom_level("cust4", 4); | ||||||||||||||||||||||||||||||||||||||||||||||
| 729 | create_custom_level("cust2", cust3); | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | create_custom_level("cust1", cust2); | ||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 32 | ▶ | }) if (${Log::Log4perl::Level::LEVELS{$cust_prio}}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 31 | Log::Log4perl::Level::add_priority($level, $cust_prio, $syslog_equiv, | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | $log_dispatch_level); | ||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 31 | print("Adding prio $level at $cust_prio\n") if _INTERNAL_DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # get $LEVEL into namespace of Log::Log4perl::Logger to | ||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # create $logger->foo nd $logger->is_foo | ||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 31 | my $name = "Log::Log4perl::Logger::"; | |||||||||||||||||||||||||||||||||||||||||||||
| 741 | 31 | my $key = $level; | |||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 54 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | # be sure to use ${Log...} as CVS adds log entries for Log | ||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 31 | *{"$name$key"} = \${Log::Log4perl::Level::PRIORITY{$level}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | # now, stick it in the caller's namespace | ||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 31 | $name = caller(0) . "::"; | |||||||||||||||||||||||||||||||||||||||||||||
| 749 | 31 | *{"$name$key"} = \${Log::Log4perl::Level::PRIORITY{$level}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 750 | 54 | ▶ | use strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 31 | create_log_level_methods($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 31 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||
| 758 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 759 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # if we were hackin' lisp (or scheme), we'd be returning some lambda | ||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # expressions. But we aren't. :) So we'll just create some strings and | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # eval them. | ||||||||||||||||||||||||||||||||||||||||||||||
| 763 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 463 | ▶ | sub create_log_level_methods { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_log_level_methods: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | ######################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 463 | ▶ | my $level = shift || die("create_log_level_methods: " . | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || die('create_log_level_methods: forgot to pass in a level string!')
MC/DC0%0/1
shift() || die('create_log_level_methods: forgot to pass in a level string!')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | "forgot to pass in a level string!"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 463 | my $lclevel = lc($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | 463 | my $levelint = uc($level) . "_INT"; | |||||||||||||||||||||||||||||||||||||||||||||
| 770 | 463 | my $initial_cap = ucfirst($lclevel); | |||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 54 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | # This is a bit better way to create code on the fly than eval'ing strings. | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | # -erik | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 463 | ▶ | *{__PACKAGE__ . "::$lclevel"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 359 | if(_INTERNAL_DEBUG) { | |||||||||||||||||||||||||||||||||||||||||||||
| 779 | my $level_disp = (defined $_[0]->{level} ? $_[0]->{level} | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | : "[undef]"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 781 | print "$lclevel: ($_[0]->{category}/$level_disp) [@_]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 359 | ▶ | init_warn() unless $INITIALIZED or $NON_INIT_WARNED; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Log::Log4perl::Logger::INITIALIZED or $Log::Log4perl::Logger::NON_INIT_WARNED
MC/DC50%1/2
$Log::Log4perl::Logger::INITIALIZED or $Log::Log4perl::Logger::NON_INIT_WARNED
$Log::Log4perl::Logger::INITIALIZED
$Log::Log4perl::Logger::NON_INIT_WARNED
Truth table66%2/3
A or B
A= $Log::Log4perl::Logger::INITIALIZEDB= $Log::Log4perl::Logger::NON_INIT_WARNED
| |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 359 | ▶ | $_[0]->{$level}->(@_, $level) if defined $_[0]->{$level}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 463 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | # Added these to have is_xxx functions as fast as xxx functions | ||||||||||||||||||||||||||||||||||||||||||||||
| 788 | # -ms | ||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 463 | my $islevel = "is_" . $level; | |||||||||||||||||||||||||||||||||||||||||||||
| 791 | 463 | my $islclevel = "is_" . $lclevel; | |||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 463 | ▶ | *{__PACKAGE__ . "::is_$lclevel"} = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 86 | $_[0]->{$islevel}->($_[0], $islclevel); | |||||||||||||||||||||||||||||||||||||||||||||
| 795 | 463 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # Add the isXxxEnabled() methods as identical to the is_xxx | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # functions. - dviner | ||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 463 | *{__PACKAGE__ . "::is".$initial_cap."Enabled"} = | |||||||||||||||||||||||||||||||||||||||||||||
| 801 | 463 | \&{__PACKAGE__ . "::is_$lclevel"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 54 | ▶ | use strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 463 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | #now lets autogenerate the logger subs based on the defined priorities | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 54 | foreach my $level (keys %Log::Log4perl::Level::PRIORITY){ | |||||||||||||||||||||||||||||||||||||||||||||
| 810 | 432 | create_log_level_methods($level); | |||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 1 | ▶ | sub init_warn { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_warn: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | CORE::warn "Log4perl: Seems like no initialization happened. " . | |||||||||||||||||||||||||||||||||||||||||||||
| 817 | "Forgot to call init()?\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 818 | # Only tell this once; | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1 | $NON_INIT_WARNED = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 822 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # call me from a sub-func to spew the sub-func's caller | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | sub callerline { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callerline: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my $message = join ('', @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $caller_offset = | |||||||||||||||||||||||||||||||||||||||||||||
| 829 | Log::Log4perl::caller_depth_offset( | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | $Log::Log4perl::caller_depth + 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my ($pack, $file, $line) = caller($caller_offset); | |||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | if (not chomp $message) { # no newline | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $message .= " at $file line $line"; | |||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # Someday, we'll use Threads. Really. | ||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | if (defined &Thread::tid) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $tid = Thread->self->tid; | |||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | $message .= " thread $tid" if $tid; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | return ($message, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | sub and_warn { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and_warn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | CORE::warn(callerline($self->warning_render(@_))); | |||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | sub and_die { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and_die: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 856 | ####################################################### | ||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | my $arg = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | my($msg) = callerline($self->warning_render(@_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | if($DIE_DEBUG) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $DIE_DEBUG_BUFFER = "DIE_DEBUG: $msg"; | |||||||||||||||||||||||||||||||||||||||||||||
| 864 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | die("$msg\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | die $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | sub logwarn { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logwarn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 878 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | if ($self->is_warn()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 881 | # Since we're one caller level off now, compensate for that. | ||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my @chomped = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | chomp($chomped[-1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | $self->warn(@chomped); | |||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $self->and_warn(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | sub logdie { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logdie: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if ($self->is_fatal()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # Since we're one caller level off now, compensate for that. | ||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my @chomped = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | chomp($chomped[-1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->fatal(@chomped); | |||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||
| 905 | $Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | $self->and_die(@_) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 907 | exit($Log::Log4perl::LOGEXIT_CODE); | ||||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||
| 910 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | sub logexit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logexit: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 912 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 916 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | ▶ | if ($self->is_fatal()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | # Since we're one caller level off now, compensate for that. | ||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | my @chomped = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | chomp($chomped[-1]); | |||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | $self->fatal(@chomped); | |||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | exit $Log::Log4perl::LOGEXIT_CODE; | |||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # clucks and carps are WARN level | ||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | sub logcluck { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logcluck: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 935 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | local $Carp::CarpLevel = | |||||||||||||||||||||||||||||||||||||||||||||
| 938 | $Carp::CarpLevel + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $msg = $self->warning_render(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | if ($self->is_warn()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my $message = Carp::longmess($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | foreach (split(/\n/, $message)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | $self->warn("$_\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | Carp::cluck($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||
| 952 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | ▶ | sub logcarp { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logcarp: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 954 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 960 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $msg = $self->warning_render(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | if ($self->is_warn()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | my $message = Carp::shortmess($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | foreach (split(/\n/, $message)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | $self->warn("$_\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | Carp::carp($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||
| 974 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # croaks and confess are FATAL level | ||||||||||||||||||||||||||||||||||||||||||||||
| 976 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | sub logcroak { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logcroak: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 978 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my $arg = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | my $msg = $self->warning_render(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | local $Carp::CarpLevel = | |||||||||||||||||||||||||||||||||||||||||||||
| 985 | $Carp::CarpLevel + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 988 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | if ($self->is_fatal()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $message = Carp::shortmess($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | foreach (split(/\n/, $message)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | $self->fatal("$_\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $croak_msg = $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $croak_msg = $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | $Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | ▶ | Carp::croak($croak_msg) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | exit($Log::Log4perl::LOGEXIT_CODE); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | sub logconfess { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logconfess: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my $arg = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | local $Carp::CarpLevel = | |||||||||||||||||||||||||||||||||||||||||||||
| 1015 | $Carp::CarpLevel + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 1018 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | my $msg = $self->warning_render(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | if ($self->is_fatal()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my $message = Carp::longmess($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | foreach (split(/\n/, $message)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $self->fatal("$_\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | my $confess_msg = $arg; | |||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | if( $Log::Log4perl::STRINGIFY_DIE_MESSAGE ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $confess_msg = $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | $Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | confess($confess_msg) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | exit($Log::Log4perl::LOGEXIT_CODE); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # in case people prefer to use error for warning | ||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | sub error_warn { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_warn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 1048 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | ▶ | if ($self->is_error()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | $self->error(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $self->and_warn(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | sub error_die { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_die: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | local $Log::Log4perl::caller_depth = | |||||||||||||||||||||||||||||||||||||||||||||
| 1063 | $Log::Log4perl::caller_depth + 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | my $msg = $self->warning_render(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | ▶ | if ($self->is_error()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | $self->error($msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | $Log::Log4perl::LOGDIE_MESSAGE_ON_STDERR ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | $self->and_die($msg) : | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | exit($Log::Log4perl::LOGEXIT_CODE); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 4 | ▶ | sub more_logging { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
more_logging: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 4 | my ($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 4 | return $self->dec_level(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 2 | ▶ | sub inc_level { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inc_level: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 2 | my ($self, $delta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 2 | ▶ | $delta ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$delta ||= 1
MC/DC0%0/1
$delta ||= 1
$delta
Truth table50%1/2
A
A= $delta
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 2 | $self->level(Log::Log4perl::Level::get_higher_level($self->level(), | |||||||||||||||||||||||||||||||||||||||||||||
| 1091 | $delta)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 2 | $self->set_output_methods; | |||||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 1 | ▶ | sub less_logging { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
less_logging: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 1 | my ($self) = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 1 | return $self->inc_level(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 5 | ▶ | sub dec_level { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dec_level: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | ################################################## | ||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 5 | my ($self, $delta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 5 | ▶ | $delta ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$delta ||= 1
MC/DC100%1/1
$delta ||= 1
$delta
Truth table100%2/2
A
A= $delta
| |||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 5 | $self->level(Log::Log4perl::Level::get_lower_level($self->level(), $delta)); | |||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 5 | $self->set_output_methods; | |||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 54 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||