File Coverage

blib/lib/JMAP/Tester/Logger/HTTP.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 39 39 100.0


line stmt bran cond sub pod time code
1 2     2   435534 use v5.14.0;
  2         9  
2             package JMAP::Tester::Logger::HTTP 0.109;
3              
4 2     2   672 use Moo;
  2         11569  
  2         18  
5              
6 2     2   3131 use namespace::clean;
  2         22225  
  2         21  
7              
8 2     2   1242 use experimental 'signatures';
  2         1816  
  2         15  
9              
10             my %counter;
11              
12 2     2   3 sub _log_generic ($self, $tester, $type, $thing) {
  2         1  
  2         3  
  2         2  
  2         3  
  2         2  
13 2         5 my $i = $counter{$type}++;
14 2         23 my $ident = $tester->ident;
15 2         25 $self->write("=== BEGIN \U$type\E $$.$i ($ident) ===\n");
16 2         16 $self->write( $thing->as_string );
17 2         21 $self->write("=== END \U$type\E $$.$i ($ident) ===\n");
18 2         6 return;
19             }
20              
21             for my $which (qw(jmap misc upload download)) {
22             for my $what (qw(request response)) {
23             my $method = "log_${which}_${what}";
24 2     2   1113 no strict 'refs';
  2         6  
  2         409  
25 2     2   4 *$method = sub ($self, $tester, $arg) {
  2         4  
  2         2  
  2         3  
  2         3  
26 2         9 $self->_log_generic($tester, "$which $what", $arg->{"http_$what"});
27             }
28             }
29             }
30              
31             with 'JMAP::Tester::Logger';
32              
33             1;
34              
35             __END__