File Coverage

blib/lib/Regru/API/Role/Loggable.pm
Criterion Covered Total %
statement 27 27 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Regru::API::Role::Loggable;
2              
3             # ABSTRACT: something that produces a debug messages
4              
5 14     14   16769 use strict;
  14         35  
  14         411  
6 14     14   72 use warnings;
  14         28  
  14         323  
7 14     14   64 use Moo::Role;
  14         28  
  14         100  
8 14     14   5242 use namespace::autoclean;
  14         13625  
  14         119  
9 14     14   9475 use Data::Dumper;
  14         90975  
  14         907  
10 14     14   110 use Carp;
  14         29  
  14         2239  
11              
12             our $VERSION = '0.051'; # VERSION
13             our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY
14              
15             sub debug_warn {
16 6     6 1 21032 my ($self, @garbage) = @_;
17              
18 6         15 local $Data::Dumper::Terse = 1;
19 6         11 local $Data::Dumper::Indent = 0;
20 6         11 local $Data::Dumper::Useqq = 1;
21 6         10 local $Data::Dumper::Pair = ': ';
22 6         11 local $Data::Dumper::Sortkeys = 1;
23              
24 6 100       25 my $msg = join ' ' => map { (ref $_ ? Dumper($_) : $_) } @garbage;
  17         216  
25              
26 6         815 carp $msg;
27             }
28              
29             1; # End of Regru::API::Role::Loggable
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Regru::API::Role::Loggable - something that produces a debug messages
40              
41             =head1 VERSION
42              
43             version 0.051
44              
45             =head1 SYNOPSIS
46              
47             package Regru::API::Dummy;
48             ...
49             with 'Regru::API::Role::Loggable';
50              
51             # inside some method
52             sub foo {
53             my ($self) = @_;
54             ...
55             $ref = { -answer => 42 };
56             $sclr = 'quux';
57              
58             $self->debug_warn('Foo:', 'bar', 'baz', $ref, $sclr, qw(knock, knock));
59             # will warn
60             # Foo: bar baz {"-answer": 42} quux knock, knock at ...
61             }
62              
63             =head1 DESCRIPTION
64              
65             Role provides the method which will be useful for debugging requests and responses.
66              
67             =head1 METHODS
68              
69             =head2 debug_warn
70              
71             Produces a warning message for a given list of agruments. All passed references (ArrayRef, HashRef or blessed)
72             will be flatten to the scalars. Output message will be done by joining scalars with C<space> character as separator.
73              
74             =head1 SEE ALSO
75              
76             L<Regru::API>
77              
78             L<Regru::API::Role::Client>
79              
80             =head1 BUGS
81              
82             Please report any bugs or feature requests on the bugtracker website
83             L<https://github.com/regru/regru-api-perl/issues>
84              
85             When submitting a bug or request, please include a test-file or a
86             patch to an existing test-file that illustrates the bug or desired
87             feature.
88              
89             =head1 AUTHORS
90              
91             =over 4
92              
93             =item *
94              
95             Polina Shubina <shubina@reg.ru>
96              
97             =item *
98              
99             Anton Gerasimov <a.gerasimov@reg.ru>
100              
101             =back
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is copyright (c) 2013 by REG.RU LLC.
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as the Perl 5 programming language system itself.
109              
110             =cut