Skinny/Profiler/Trace.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 58 CC 4 SCAR 17.0
CC
4
Cov
0%
record_query
12.0
new
6.0
reset
2.0
CRAP 5.5
1 package DBIx::Skinny::Profiler::Trace;
2 use strict;
3 use warnings;
4 use base 'DBIx::Skinny::Profiler';
5 use IO::Handle;
6
7 sub new {
8 my $class = shift;
9
10 my $self = bless {}, $class;
11 my $env = $ENV{SKINNY_TRACE};
12
13 my $fh;
14 if ( $env && $env =~ /=(.+)$/ ) {
15 my $fname = $1;
16 open( $fh, '>>', $fname ) or die("cannot open '$fname': $!");
17 }
18 else {
19 $fh = *STDERR;
20 }
21
22 autoflush $fh;
23  
24 $self->{fh} = $fh;
25  
26 $self;
27 }
28
29 sub record_query {
30 my ( $self, $sql, $bind ) = @_;
31 my $log = $self->_normalize($sql);
32
33 if ( ref $bind eq 'ARRAY' ) {
34 my @binds;
35 push @binds, defined $_ ? $_ : 'undef' for @$bind;
36 $log .= ' :binds ' . join ', ', @binds;
37 }
38
39 my $fh = $self->{fh};
40 print $fh $log, "\n";
41 }
42
43 sub reset {}
44 sub query_log {}
45
46 1;
47  
48 __END__