File Coverage

blib/lib/Sentry/Logger.pm
Criterion Covered Total %
statement 37 50 74.0
branch 1 4 25.0
condition 2 3 66.6
subroutine 8 11 72.7
pod 0 5 0.0
total 48 73 65.7


line stmt bran cond sub pod time code
1             use Mojo::Base -base, -signatures;
2 4     4   22  
  4         7  
  4         22  
3             use Exporter qw(import);
4 4     4   859 use List::Util 'any';
  4         9  
  4         106  
5 4     4   20  
  4         12  
  4         2011  
6             our @EXPORT_OK = qw(logger);
7              
8             has context => 'Sentry';
9             has active_contexts => sub { [split(/,/, $ENV{DEBUG} // '')] };
10              
11             return any { $context =~ $_ } $self->active_contexts->@*;
12 26     26   33 }
  26         37  
  26         37  
  26         29  
13 26     0   120  
  0         0  
14             return unless $self->_should_print($context);
15             print { $error ? *STDERR : *STDOUT } qq{[$context] $message\n};
16 26     26   32 }
  26         31  
  26         33  
  26         39  
  26         34  
  26         43  
17 26 50       72  
18 0 0       0 $self->_print($message, $context);
  0         0  
19             }
20              
21 25     25 0 409 $self->_print($message, $context, 1);
  25         33  
  25         31  
  25         32  
  25         31  
22 25         67 }
23              
24             $self->_print($message, $context, 1);
25 0     0 0 0 }
  0         0  
  0         0  
  0         0  
  0         0  
26 0         0  
27             $self->enabled(1);
28             }
29 1     1 0 2  
  1         3  
  1         2  
  1         4  
  1         6  
30 1         6 my $Instance;
31              
32             $Instance //= Sentry::Logger->new;
33 0     0 0 0 return $Instance;
  0         0  
  0         0  
34 0         0 }
35              
36             1;