← Index
NYTProf Performance Profile   « line view »
For nd2: #2 manager: init
  Run on Thu May 2 17:38:58 2019
Reported on Thu May 2 17:40:49 2019

Filename/appl/netdisco/perl5/lib/perl5/Dancer/Logger.pm
StatementsExecuted 99 statements in 529µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3311262µs10.1msDancer::Logger::::debugDancer::Logger::debug
3311214µs214µsDancer::Logger::::_serializeDancer::Logger::_serialize
0000s0sDancer::Logger::::BEGINDancer::Logger::BEGIN
0000s0sDancer::Logger::::coreDancer::Logger::core
0000s0sDancer::Logger::::errorDancer::Logger::error
0000s0sDancer::Logger::::infoDancer::Logger::info
0000s0sDancer::Logger::::initDancer::Logger::init
0000s0sDancer::Logger::::loggerDancer::Logger::logger
0000s0sDancer::Logger::::warningDancer::Logger::warning
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Dancer::Logger;
2our $AUTHORITY = 'cpan:SUKRIA';
3#ABSTRACT: common interface for logging in Dancer
4$Dancer::Logger::VERSION = '1.3512';
5# Factory for logger engines
6
7use strict;
8use warnings;
9use Data::Dumper;
10use Dancer::Engine;
11
12# singleton used for logging messages
13my $logger;
14sub logger {$logger}
15
16sub init {
17 my ($class, $name, $config) = @_;
18 $logger = Dancer::Engine->build(logger => $name, $config);
19}
20
21
# spent 214µs within Dancer::Logger::_serialize which was called 33 times, avg 6µs/call: # 33 times (214µs+0s) by Dancer::Logger::debug at line 37, avg 6µs/call
sub _serialize {
223329µs my @vars = @_;
23
24 return join q{}, map {
2533179µs ref $_
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
36sub core { defined($logger) and $logger->core( _serialize(@_) ) }
3733320µs669.88ms
# spent 10.1ms (262µs+9.88) within Dancer::Logger::debug which was called 33 times, avg 307µs/call: # 33 times (262µs+9.88ms) by App::Netdisco::Util::Device::_bail_msg at line 141 of Dancer.pm, avg 307µs/call
sub debug { defined($logger) and $logger->debug( _serialize(@_) ) }
# spent 9.66ms making 33 calls to Dancer::Logger::Abstract::debug, avg 293µs/call # spent 214µs making 33 calls to Dancer::Logger::_serialize, avg 6µs/call
38sub info { defined($logger) and $logger->info( _serialize(@_) ) }
39sub warning { defined($logger) and $logger->warning( _serialize(@_) ) }
40sub error { defined($logger) and $logger->error( _serialize(@_) ) }
41
421;
43
44=pod
45
46=encoding UTF-8
47
48=head1 NAME
49
50Dancer::Logger - common interface for logging in Dancer
51
52=head1 VERSION
53
54version 1.3512
55
56=head1 DESCRIPTION
57
58This module is the wrapper that provides support for different
59logger engines.
60
61=head1 USAGE
62
63=head2 Default engine
64
65The setting B<logger> defines which logger engine to use.
66If this setting is not set, logging will not be available in the application
67code.
68
69Dancer comes with the logger engines L<Dancer::Logger::File> and
70L<Dancer::Logger::Console>, but more are available on the CPAN.
71
72=head2 Configuration
73
74The B<logger> configuration variable tells Dancer which engine to use.
75
76You can change it either in your config.yml file:
77
78 # logging to console
79 logger: "console"
80
81Or in the application code:
82
83 # logging to file
84 set logger => 'file';
85
86The log format can also be configured,
87please see L<Dancer::Logger::Abstract/"logger_format"> for details.
88
89=head2 Auto-serializing
90
91The loggers allow auto-serializing of all inputs:
92
93 debug( 'User credentials: ', \%creds );
94
95Will provide you with an output in a single log message of the string and the
96reference dump.
97
98=head1 AUTHORS
99
100This module has been written by Alexis Sukrieh. See the AUTHORS file that comes
101with this distribution for details.
102
103=head1 LICENSE
104
105This module is free software and is released under the same terms as Perl
106itself.
107
108=head1 SEE ALSO
109
110See L<Dancer> for details about the complete framework.
111
112You can also search the CPAN for existing engines in the Dancer::Logger
113namespace : L<http://search.cpan.org/search?query=Dancer%3A%3ALogger>.
114
115=head1 AUTHOR
116
117Dancer Core Developers
118
119=head1 COPYRIGHT AND LICENSE
120
121This software is copyright (c) 2010 by Alexis Sukrieh.
122
123This is free software; you can redistribute it and/or modify it under
124the same terms as the Perl 5 programming language system itself.
125
126=cut
127
128__END__