blib/lib/Lemonldap/NG/Common/AuditLogger/UserLoggerJSON.pm

filter: Statementstmt 100% 25 / 25 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 89.1% 33 / 37 CC 4 SCAR 6.4
CC
4
Cov
93%
log
3.0
new
2.0
BEGIN
1.0
CRAP 1.9
« blib/lib/Lemonldap/NG/Common/OpenIDConnect/Constants.pm ↑ Summary blib/lib/Lemonldap/NG/Common/AuditLogger/UserLoggerCompat.pm »
1 package Lemonldap::NG::Common::AuditLogger::UserLoggerJSON;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '2.21.0';
8  
9 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
10 2 my ( $class, $psgi_or_handler ) = @_;
11 2 my $self = bless {}, $class;
12  
13 2 ▶ $self->{userLogger} = $psgi_or_handler->userLogger
Branch: 1 branch
BranchTrueFalseTotal
$self->{"userLogger"} = $psgi_or_handler->userLogger or die "Missing userLogger" 2 0 2
14 or die 'Missing userLogger';
15 2 weaken $self->{userLogger};
16 2 my $json = JSON->new->canonical;
17 2 ▶ $self->{encode} = sub { $json->encode(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
18 2 return $self;
19 }
20  
21 4 ▶sub log {
Subroutine log: called CC=3 SCAR=11.0
Pod undocumented
22 4 my ( $self, $req, %fields ) = @_;
23  
24 4 my $message = $fields{message};
25 4 foreach ( keys %fields ) {
26 6 ▶ delete $fields{$_} if ref( $fields{$_} );
Branch: 1 branch
BranchTrueFalseTotal
if ref $fields{$_} 0 6 6
27 }
28 4 $fields{remote_addr} = $req->address;
29 4 $self->{userLogger}->notice( $self->{encode}->( \%fields ) );
30 }
31  
32 1 1;
« blib/lib/Lemonldap/NG/Common/OpenIDConnect/Constants.pm ↑ Summary blib/lib/Lemonldap/NG/Common/AuditLogger/UserLoggerCompat.pm »