| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: Log4perl.pm 279 2006-09-01 18:36:01Z martin $ |
|
2
|
|
|
|
|
|
|
require 5.008; |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
24488
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
68
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
152
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp qw(croak cluck); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
128
|
|
|
7
|
2
|
|
|
2
|
|
2636
|
use Log::Log4perl; |
|
|
2
|
|
|
|
|
112726
|
|
|
|
2
|
|
|
|
|
13
|
|
|
8
|
2
|
|
|
2
|
|
2467
|
use Data::Dumper; |
|
|
2
|
|
|
|
|
16944
|
|
|
|
2
|
|
|
|
|
178
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package DBIx::Log4perl; |
|
11
|
2
|
|
|
2
|
|
1346
|
use DBIx::Log4perl::Constants qw (:masks $LogMask); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
407
|
|
|
12
|
2
|
|
|
2
|
|
1233
|
use DBIx::Log4perl::db; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
64
|
|
|
13
|
2
|
|
|
2
|
|
1341
|
use DBIx::Log4perl::st; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
3182
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.26'; |
|
16
|
|
|
|
|
|
|
require Exporter; |
|
17
|
|
|
|
|
|
|
our @ISA = qw(Exporter DBI); # look in DBI for anything we don't do |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT = (); # export nothing by default |
|
20
|
|
|
|
|
|
|
our @EXPORT_MASKS = qw(DBIX_L4P_LOG_DEFAULT |
|
21
|
|
|
|
|
|
|
DBIX_L4P_LOG_ALL |
|
22
|
|
|
|
|
|
|
DBIX_L4P_LOG_INPUT |
|
23
|
|
|
|
|
|
|
DBIX_L4P_LOG_OUTPUT |
|
24
|
|
|
|
|
|
|
DBIX_L4P_LOG_CONNECT |
|
25
|
|
|
|
|
|
|
DBIX_L4P_LOG_TXN |
|
26
|
|
|
|
|
|
|
DBIX_L4P_LOG_ERRCAPTURE |
|
27
|
|
|
|
|
|
|
DBIX_L4P_LOG_WARNINGS |
|
28
|
|
|
|
|
|
|
DBIX_L4P_LOG_ERRORS |
|
29
|
|
|
|
|
|
|
DBIX_L4P_LOG_DBDSPECIFIC |
|
30
|
|
|
|
|
|
|
DBIX_L4P_LOG_DELAYBINDPARAM |
|
31
|
|
|
|
|
|
|
DBIX_L4P_LOG_SQL |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
our %EXPORT_TAGS= (masks => \@EXPORT_MASKS); |
|
34
|
|
|
|
|
|
|
Exporter::export_ok_tags('masks'); # all tags must be in EXPORT_OK |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _dbix_l4p_debug { |
|
37
|
0
|
|
|
0
|
|
|
my ($self, $h, $level, $thing, @args) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
$h = $self->{private_DBIx_Log4perl} if !defined($h); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
return unless $h->{logger}->is_debug(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
local $Data::Dumper::Indent = 0; |
|
44
|
0
|
|
|
|
|
|
local $Data::Dumper::Quotekeys = 0; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level |
|
47
|
|
|
|
|
|
|
if $level; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if (scalar(@args) > 1) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
|
|
$h->{logger}->debug( |
|
51
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([\@args], [$thing])}) |
|
52
|
0
|
|
|
|
|
|
} elsif (ref($thing) eq 'CODE') { |
|
53
|
0
|
|
|
|
|
|
$h->{logger}->debug($thing); |
|
54
|
|
|
|
|
|
|
} elsif (ref($args[0])) { |
|
55
|
0
|
|
|
0
|
|
|
$h->{logger}->debug( |
|
56
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([$args[0]], [$thing])}) |
|
57
|
0
|
|
|
|
|
|
} elsif (scalar(@args) == 1) { |
|
58
|
0
|
0
|
|
|
|
|
if (!defined($args[0])) { |
|
59
|
0
|
|
|
|
|
|
$h->{logger}->debug("$thing:"); |
|
60
|
|
|
|
|
|
|
} else { |
|
61
|
0
|
|
|
|
|
|
$h->{logger}->debug("$thing: " . DBI::neat($args[0])); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} else { |
|
64
|
0
|
|
|
|
|
|
$h->{logger}->debug($thing); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
|
return; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _dbix_l4p_info { |
|
70
|
0
|
|
|
0
|
|
|
my ($self, $level, $thing) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $h = $self->{private_DBIx_Log4perl}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
return unless $h->{logger}->is_info(); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level |
|
77
|
|
|
|
|
|
|
if $level; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$h->{logger}->info($thing); |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
sub _dbix_l4p_warning { |
|
84
|
0
|
|
|
0
|
|
|
my ($self, $level, $thing, @args) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $h = $self->{private_DBIx_Log4perl}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
return unless $h->{logger}->is_warn(); |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
local $Data::Dumper::Indent = 0; |
|
91
|
0
|
|
|
|
|
|
local $Data::Dumper::Quotekeys = 0; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level |
|
94
|
|
|
|
|
|
|
if $level; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if (scalar(@args) > 1) { |
|
|
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
0
|
|
|
$h->{logger}->warn( |
|
98
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([\@args], [$thing])}) |
|
99
|
0
|
|
|
|
|
|
} elsif (ref($args[0])) { |
|
100
|
0
|
|
|
0
|
|
|
$h->{logger}->warn( |
|
101
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([$args[0]], [$thing])}) |
|
102
|
0
|
|
|
|
|
|
} else { |
|
103
|
0
|
|
|
|
|
|
$h->{logger}->warn("$thing: " . DBI::neat($args[0])); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
0
|
|
|
|
|
|
return; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _dbix_l4p_error { |
|
109
|
0
|
|
|
0
|
|
|
my ($self, $level, $thing, @args) = @_; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $h = $self->{private_DBIx_Log4perl}; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
return unless $h->{logger}->is_error(); |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
local $Data::Dumper::Indent = 0; |
|
116
|
0
|
|
|
|
|
|
local $Data::Dumper::Quotekeys = 0; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + $level |
|
119
|
|
|
|
|
|
|
if $level; |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if (scalar(@args) > 1) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
122
|
0
|
|
|
0
|
|
|
$h->{logger}->error( |
|
123
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([\@args], [$thing])}) |
|
124
|
0
|
|
|
|
|
|
} elsif (ref($thing) eq 'CODE') { |
|
125
|
0
|
|
|
|
|
|
$h->{logger}->error($thing); |
|
126
|
|
|
|
|
|
|
} elsif (ref($args[0])) { |
|
127
|
0
|
|
|
0
|
|
|
$h->{logger}->error( |
|
128
|
|
|
|
|
|
|
sub {Data::Dumper->Dump([$args[0]], [$thing])}) |
|
129
|
0
|
|
|
|
|
|
} else { |
|
130
|
0
|
|
|
|
|
|
$h->{logger}->error("$thing: " . DBI::neat($args[0])); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
0
|
|
|
|
|
|
return; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _dbix_l4p_attr_map { |
|
136
|
0
|
|
|
0
|
|
|
return {dbix_l4p_logger => 'logger', |
|
137
|
|
|
|
|
|
|
dbix_l4p_init => 'init', |
|
138
|
|
|
|
|
|
|
dbix_l4p_class => 'class', |
|
139
|
|
|
|
|
|
|
dbix_l4p_logmask => 'logmask', |
|
140
|
|
|
|
|
|
|
dbix_l4p_ignore_err_regexp => 'err_regexp' |
|
141
|
|
|
|
|
|
|
}; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub dbix_l4p_getattr { |
|
145
|
0
|
|
|
0
|
1
|
|
my ($self, $item) = @_; |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
0
|
0
|
|
|
|
croak ('wrong arguments - dbix_l4p_getattr(attribute_name)') |
|
148
|
|
|
|
|
|
|
if (scalar(@_) != 2 || !defined($_[1])); |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my $m = _dbix_l4p_attr_map(); |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $h = $self->{private_DBIx_Log4perl}; |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if (!exists($m->{$item})) { |
|
155
|
0
|
|
|
|
|
|
warn "$item does not exist"; |
|
156
|
0
|
|
|
|
|
|
return undef; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
0
|
|
|
|
|
|
return $h->{$m->{$item}}; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub dbix_l4p_setattr { |
|
162
|
0
|
|
|
0
|
1
|
|
my ($self, $item, $value) = @_; |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
0
|
0
|
|
|
|
croak ('wrong arguments - dbix_l4p_setattr(attribute_name, value)') |
|
165
|
|
|
|
|
|
|
if (scalar(@_) != 3 || !defined($_[1])); |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $m = _dbix_l4p_attr_map(); |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $h = $self->{private_DBIx_Log4perl}; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
if (!exists($m->{$item})) { |
|
172
|
0
|
|
|
|
|
|
warn "$item does not exist"; |
|
173
|
0
|
|
|
|
|
|
return undef; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
0
|
|
|
|
|
|
$h->{$m->{$item}} = $value; |
|
176
|
0
|
|
|
|
|
|
1; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub connect { |
|
180
|
|
|
|
|
|
|
|
|
181
|
0
|
|
|
0
|
1
|
|
my ($drh, $dsn, $user, $pass, $attr) = @_; |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my $dbh = $drh->SUPER::connect($dsn, $user, $pass, $attr); |
|
184
|
0
|
0
|
|
|
|
|
return $dbh if (!$dbh); |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# |
|
187
|
|
|
|
|
|
|
# Enable dbms_output for DBD::Oracle else turn off DBDSPECIFIC as we have |
|
188
|
|
|
|
|
|
|
# no support for DBDSPECIFIC in any other drivers. |
|
189
|
|
|
|
|
|
|
# BUT only enable it if the log handle is doing debug as we only call |
|
190
|
|
|
|
|
|
|
# dbms_output_get in that case. |
|
191
|
|
|
|
|
|
|
# |
|
192
|
0
|
|
|
|
|
|
my $h = $dbh->{private_DBIx_Log4perl}; |
|
193
|
0
|
|
|
|
|
|
$h->{dbd_specific} = 1; |
|
194
|
0
|
0
|
0
|
|
|
|
if (($h->{logger}->is_debug()) && |
|
|
|
|
0
|
|
|
|
|
|
195
|
|
|
|
|
|
|
($h->{logmask} & DBIX_L4P_LOG_DBDSPECIFIC) && |
|
196
|
|
|
|
|
|
|
($h->{driver} eq 'Oracle')) { |
|
197
|
0
|
|
|
|
|
|
$dbh->func('dbms_output_enable'); |
|
198
|
|
|
|
|
|
|
} else { |
|
199
|
0
|
|
|
|
|
|
$h->{logmask} &= ~DBIX_L4P_LOG_DBDSPECIFIC; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
0
|
|
|
|
|
|
$h->{dbd_specific} = 0; |
|
202
|
0
|
|
|
|
|
|
return $dbh; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub dbix_l4p_logdie |
|
206
|
|
|
|
|
|
|
{ |
|
207
|
0
|
|
|
0
|
1
|
|
my ($drh, $msg) = @_; |
|
208
|
0
|
|
|
|
|
|
_error_handler($msg, $drh); |
|
209
|
0
|
|
|
|
|
|
die "$msg"; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
__END__ |