File Coverage

blib/lib/GraphQL/Debug.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 21 95.2


line stmt bran cond sub pod time code
1             package GraphQL::Debug;
2              
3 22     22   401 use 5.014;
  22         72  
4 22     22   103 use strict;
  22         45  
  22         395  
5 22     22   91 use warnings;
  22         34  
  22         573  
6 22     22   105 use Exporter 'import';
  22         37  
  22         2651  
7              
8             our @EXPORT_OK = qw(_debug);
9              
10             =head1 NAME
11              
12             GraphQL::Debug - debug GraphQL
13              
14             =cut
15              
16             =head1 SYNOPSIS
17              
18             use GraphQL::Debug qw(_debug);
19             use constant DEBUG => $ENV{GRAPHQL_DEBUG};
20             DEBUG and _debug('current_function', $value1, $value2);
21              
22             =head1 DESCRIPTION
23              
24             Creates debugging output when called. Intended to have its calls optimised
25             out when debugging not sought, using the construct shown above. The
26             values given will be passed through L<Data::Dumper/Dumper>.
27              
28             =cut
29              
30             # TODO make log instead of diag
31             sub _debug {
32 1     1   9272 my $func = shift;
33 1         8 require Test::More;
34 1 50       7 Test::More::diag("$func: ", Test::More::explain(@_ == 1 ? @_ : [ @_ ]));
35             }
36              
37             1;