File Coverage

blib/lib/Class/ReluctantORM/Monitor/Dump.pm
Criterion Covered Total %
statement 9 20 45.0
branch n/a
condition 0 2 0.0
subroutine 3 10 30.0
pod 7 7 100.0
total 19 39 48.7


line stmt bran cond sub pod time code
1             package Class::ReluctantORM::Monitor::Dump;
2              
3             =head1 NAME
4              
5             Class::ReluctantORM::Monitor::Dump - Dump SQL structures
6              
7             =head1 SYNOPSIS
8              
9             use aliased 'Class::ReluctantORM::Monitor::Dump' => 'Monitor::Dump';
10              
11             # Create a new monitor - dumps everything, all the time, to STDERR
12             my $mon = Monitor::Dump->new();
13              
14             # List of things you can dump
15             my $mon = Monitor::Dump->new(what => qw(sql_object statement binds row));
16              
17             # When you can dump them
18             my $mon = Monitor::Dump->new(when => qw(render_begin render_transform ...));
19              
20             =head1 DESCRIPTION
21              
22             Dumps structures to the log.
23              
24             This is a basic (non-Measuring) Monitor.
25              
26             =cut
27              
28 1     1   7 use strict;
  1         3  
  1         82  
29 1     1   7 use warnings;
  1         2  
  1         29  
30 1     1   5 use base 'Class::ReluctantORM::Monitor';
  1         2  
  1         437  
31              
32             =head1 CONSTRUCTOR
33              
34             =cut
35              
36             =head2 $mon = Monitor::Dump->new(%monitor_args);
37              
38             Creates a Dump monitor.
39              
40             Identical to the usual defaults for a Monitor (all events, all data to the log) EXCEPT that the 'log' option is given a default of 'STDERR'.
41              
42             =cut
43              
44             sub new {
45 0     0 1   my $class = shift;
46 0           my %args = @_;
47 0   0       $args{log} ||= 'STDERR';
48 0           my $self = $class->SUPER::_new(%args);
49 0           return $self;
50             }
51              
52 0     0 1   sub notify_render_begin { $_[0]->_log_stuff(@_[1..$#_], event => 'render_begin'); }
53 0     0 1   sub notify_render_transform { $_[0]->_log_stuff(@_[1..$#_], event => 'render_transform'); }
54 0     0 1   sub notify_render_finish { $_[0]->_log_stuff(@_[1..$#_], event => 'render_finish'); }
55 0     0 1   sub notify_execute_begin { $_[0]->_log_stuff(@_[1..$#_], event => 'execute_begin'); }
56 0     0 1   sub notify_execute_finish { $_[0]->_log_stuff(@_[1..$#_], event => 'execute_finish'); }
57 0     0 1   sub notify_fetch_row { $_[0]->_log_stuff(@_[1..$#_], event => 'fetch_row'); }
58             #sub notify_finish { __log_stuff(@_, event => 'finish'); }
59              
60              
61             1;