blib/lib/Lemonldap/NG/Common/Logger/Sentry.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 CC 7 SCAR 37.8
CC
7
Cov
0%
new
56.0
BEGIN
2.0
BEGIN
2.0
CRAP 44.0
1 # EXPERIMENTAL LOGGER
2 #
3 # To use it:
4 # - set logger to Lemonldap::NG::Common::Logger::Sentry
5 # - set sentryDsn in lemonldap-ng.ini
6 # - use a high value for logLevel (or userLogger):error or warn, else too
7 # many issues will be created and service will reject requests
8 package Lemonldap::NG::Common::Logger::Sentry;
9  
10 use strict;
11 use Sentry::Raven;
12  
13 our $VERSION = '2.0.15';
14  
15 sub new {
16 my $self = bless {}, shift;
17 my ($conf) = @_;
18 my $show = 1;
19 $self->{raven} = Sentry::Raven->new( sentry_dsn => $conf->{sentryDsn} );
20  
21 foreach (qw(error warn notice info debug)) {
22 my $rl = $_;
23 $rl = 'warning' if ( $rl = 'warn' );
24 $rl = 'info' if ( $rl = 'notice' );
25 if ($show) {
26 eval
27 qq'sub $_ {\$_[0]->{raven}->capture_message(\$_[1],level => "$rl")}';
28 die $@ if ($@);
29 }
30 else {
31 eval qq'sub $_ {1}';
32 }
33 $show = 0 if ( $conf->{logLevel} eq $_ );
34 }
35 die "Unknown logLevel $conf->{logLevel}" if $show;
36  
37 return $self;
38 }
39  
40 1;