line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Logger; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SUKRIA'; |
3
|
|
|
|
|
|
|
#ABSTRACT: common interface for logging in Dancer |
4
|
|
|
|
|
|
|
$Dancer::Logger::VERSION = '1.3520'; |
5
|
|
|
|
|
|
|
# Factory for logger engines |
6
|
|
|
|
|
|
|
|
7
|
194
|
|
|
194
|
|
1322
|
use strict; |
|
194
|
|
|
|
|
707
|
|
|
194
|
|
|
|
|
6092
|
|
8
|
194
|
|
|
194
|
|
1047
|
use warnings; |
|
194
|
|
|
|
|
467
|
|
|
194
|
|
|
|
|
4820
|
|
9
|
194
|
|
|
194
|
|
123310
|
use Data::Dumper; |
|
194
|
|
|
|
|
1279362
|
|
|
194
|
|
|
|
|
12058
|
|
10
|
194
|
|
|
194
|
|
2917
|
use Dancer::Engine; |
|
194
|
|
|
|
|
490
|
|
|
194
|
|
|
|
|
60291
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# singleton used for logging messages |
13
|
|
|
|
|
|
|
my $logger; |
14
|
9
|
|
|
9
|
0
|
3367
|
sub logger {$logger} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
108
|
|
|
108
|
0
|
1422
|
my ($class, $name, $config) = @_; |
18
|
108
|
|
|
|
|
629
|
$logger = Dancer::Engine->build(logger => $name, $config); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _serialize { |
22
|
3010
|
|
|
3010
|
|
5421
|
my @vars = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return join q{}, map { |
25
|
3010
|
50
|
|
|
|
5041
|
ref $_ |
|
3013
|
50
|
|
|
|
15874
|
|
26
|
|
|
|
|
|
|
? Data::Dumper->new([$_]) |
27
|
|
|
|
|
|
|
->Terse(1) |
28
|
|
|
|
|
|
|
->Purity(1) |
29
|
|
|
|
|
|
|
->Indent(0) |
30
|
|
|
|
|
|
|
->Sortkeys(1) |
31
|
|
|
|
|
|
|
->Dump() |
32
|
|
|
|
|
|
|
: (defined($_) ? $_ : 'undef') |
33
|
|
|
|
|
|
|
} @vars; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
3163
|
100
|
|
3163
|
0
|
9269
|
sub core { defined($logger) and $logger->core( _serialize(@_) ) } |
37
|
6
|
50
|
|
6
|
0
|
715
|
sub debug { defined($logger) and $logger->debug( _serialize(@_) ) } |
38
|
0
|
0
|
|
0
|
0
|
0
|
sub info { defined($logger) and $logger->info( _serialize(@_) ) } |
39
|
4
|
50
|
|
4
|
0
|
479
|
sub warning { defined($logger) and $logger->warning( _serialize(@_) ) } |
40
|
40
|
50
|
|
40
|
0
|
657
|
sub error { defined($logger) and $logger->error( _serialize(@_) ) } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding UTF-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Dancer::Logger - common interface for logging in Dancer |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 1.3520 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This module is the wrapper that provides support for different |
59
|
|
|
|
|
|
|
logger engines. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 USAGE |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 Default engine |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The setting B defines which logger engine to use. |
66
|
|
|
|
|
|
|
If this setting is not set, logging will not be available in the application |
67
|
|
|
|
|
|
|
code. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Dancer comes with the logger engines L and |
70
|
|
|
|
|
|
|
L, but more are available on the CPAN. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 Configuration |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The B configuration variable tells Dancer which engine to use. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
You can change it either in your config.yml file: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# logging to console |
79
|
|
|
|
|
|
|
logger: "console" |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Or in the application code: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# logging to file |
84
|
|
|
|
|
|
|
set logger => 'file'; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The log format can also be configured, |
87
|
|
|
|
|
|
|
please see L for details. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 Auto-serializing |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The loggers allow auto-serializing of all inputs: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
debug( 'User credentials: ', \%creds ); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Will provide you with an output in a single log message of the string and the |
96
|
|
|
|
|
|
|
reference dump. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHORS |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This module has been written by Alexis Sukrieh. See the AUTHORS file that comes |
101
|
|
|
|
|
|
|
with this distribution for details. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This module is free software and is released under the same terms as Perl |
106
|
|
|
|
|
|
|
itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
See L for details about the complete framework. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
You can also search the CPAN for existing engines in the Dancer::Logger |
113
|
|
|
|
|
|
|
namespace : L. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Dancer Core Developers |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Alexis Sukrieh. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
124
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |