File: Debug.pm

package info (click to toggle)
libgraphql-perl 0.54-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 5,094; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package GraphQL::Debug;

use 5.014;
use strict;
use warnings;
use Exporter 'import';

our @EXPORT_OK = qw(_debug);

=head1 NAME

GraphQL::Debug - debug GraphQL

=cut

=head1 SYNOPSIS

  use GraphQL::Debug qw(_debug);
  use constant DEBUG => $ENV{GRAPHQL_DEBUG};
  DEBUG and _debug('current_function', $value1, $value2);

=head1 DESCRIPTION

Creates debugging output when called. Intended to have its calls optimised
out when debugging not sought, using the construct shown above. The
values given will be passed through L<Data::Dumper/Dumper>.

=cut

# TODO make log instead of diag
sub _debug {
  my $func = shift;
  require Test::More;
  Test::More::diag("$func: ", Test::More::explain(@_ == 1 ? @_ : [ @_ ]));
}

1;