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   24  
  4         8  
  4         22  
3             use Exporter qw(import);
4 4     4   789 use List::Util 'any';
  4         8  
  4         105  
5 4     4   20  
  4         8  
  4         1918  
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   31 }
  26         34  
  26         28  
  26         31  
13 26     0   135  
  0         0  
14             return unless $self->_should_print($context);
15             print { $error ? *STDERR : *STDOUT } qq{[$context] $message\n};
16 26     26   30 }
  26         35  
  26         29  
  26         27  
  26         32  
  26         32  
17 26 50       49  
18 0 0       0 $self->_print($message, $context);
  0         0  
19             }
20              
21 25     25 0 335 $self->_print($message, $context, 1);
  25         30  
  25         28  
  25         29  
  25         28  
22 25         54 }
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 1  
  1         2  
  1         2  
  1         3  
  1         6  
30 1         4 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;