line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Devel::InPageLogs::Log; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use base 'Catalyst::Log'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1704
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01_02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## # hash key to use when saving plugin data into context |
11
|
|
|
|
|
|
|
## our $plugin_dataname = '_inpagelogs'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Catalyst::Plugin::Devel::InPageLogs::Log - |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Catalyst::Plugin::Devel::InPageLogs::Log; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 PUBLIC METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 new |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
|
|
|
|
|
|
my $class = shift; |
39
|
|
|
|
|
|
|
my $dataref = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{$Catalyst::Plugin::Devel::InPageLogs::plugin_dataname} = $dataref; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 EXTENDED METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 _log |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Add plugin-specific data attributes to current request. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _log { |
57
|
|
|
|
|
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
my $level = shift; |
59
|
|
|
|
|
|
|
my $message = join( "\n", @_ ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$level = substr($level,0,1); |
62
|
|
|
|
|
|
|
my $time = _log_time_formatter(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $msg = sprintf "[%s] [%s] %s\n", $time, $level, $message; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $c = $self->{$Catalyst::Plugin::Devel::InPageLogs::plugin_dataname}; |
67
|
|
|
|
|
|
|
$c->inpagelogs_add_msg( $msg ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $passthru = $c->inpagelogs_config('passthru'); |
70
|
|
|
|
|
|
|
if( ! defined $passthru || $passthru ) { |
71
|
|
|
|
|
|
|
$self->SUPER::_log( $level, @_ ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 OVERRIDABLE METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head3 _log_time_formatter |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
# Persistent private variables for subroutine |
85
|
|
|
|
|
|
|
# Previous epoch time value input received |
86
|
|
|
|
|
|
|
my $prev_time; |
87
|
|
|
|
|
|
|
# Previous formatted string result |
88
|
|
|
|
|
|
|
my $prev_string; |
89
|
|
|
|
|
|
|
# If new time input is same as previous, then we can simply return |
90
|
|
|
|
|
|
|
# the previous formatted string result. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# Return local date/time in format MMDDpHHmmSS (e.g. 0109.191550) |
93
|
|
|
|
|
|
|
sub _log_time_formatter { |
94
|
|
|
|
|
|
|
my( $time ) = shift || time; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
unless( defined $prev_time && $prev_time == $time ) { |
97
|
|
|
|
|
|
|
$prev_time = $time; |
98
|
|
|
|
|
|
|
my( $sec, $min, $hour, $mday, $mon, $year ) = localtime($prev_time); |
99
|
|
|
|
|
|
|
$prev_string = sprintf( "%02d%02d.%02d%02d%02d", |
100
|
|
|
|
|
|
|
$mon+1, $mday, $hour, $min, $sec ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$prev_string; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# vim:ft=perl:ts=4:sw=4:et:is:hls:ss=10: |