← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:22 2014

Filename/usr/local/lib/site_perl/Log/Writer/File.pm
StatementsExecuted 19 statements in 451µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11113µs16µsLog::Writer::File::::BEGIN@2Log::Writer::File::BEGIN@2
11112µs47µsLog::Writer::File::::BEGIN@64Log::Writer::File::BEGIN@64
11110µs46µsLog::Writer::File::::BEGIN@78Log::Writer::File::BEGIN@78
11110µs10µsLog::Writer::File::::BEGIN@77Log::Writer::File::BEGIN@77
1119µs139µsLog::Writer::File::::BEGIN@66Log::Writer::File::BEGIN@66
1117µs30µsLog::Writer::File::::BEGIN@65Log::Writer::File::BEGIN@65
1117µs12µsLog::Writer::File::::BEGIN@3Log::Writer::File::BEGIN@3
1114µs4µsLog::Writer::File::::BEGIN@74Log::Writer::File::BEGIN@74
1112µs2µsLog::Writer::File::::ENDLog::Writer::File::END
0000s0sLog::Writer::File::::DESTROYLog::Writer::File::DESTROY
0000s0sLog::Writer::File::::_initLog::Writer::File::_init
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Log::Writer::File;
2224µs219µs
# spent 16µs (13+3) within Log::Writer::File::BEGIN@2 which was called: # once (13µs+3µs) by Log::Loger::BEGIN@131 at line 2
use strict;
# spent 16µs making 1 call to Log::Writer::File::BEGIN@2 # spent 3µs making 1 call to strict::import
3252µs218µs
# spent 12µs (7+5) within Log::Writer::File::BEGIN@3 which was called: # once (7µs+5µs) by Log::Loger::BEGIN@131 at line 3
use warnings;
# spent 12µs making 1 call to Log::Writer::File::BEGIN@3 # spent 5µs making 1 call to warnings::import
4
5#*******************************************************************************
6#
7# DOCUMENTATION SECTION
8#
9#*******************************************************************************
10
11=head1 NAME
12
13Log::Writer::File - Ordinary text file log writer
14
15=head1 SYNOPSIS
16
17 use Log::Writer::File;
18
19 my $writer = Log::Writer::File->new('./spool/writer-file.log');
20 my $writer = Log::Writer::File->new('./spool/writer-file.log',...);
21 # For more information about the constructor arguments and some more examples
22 # please refer to the Log::Writer::Handle(3) manual page
23
24 $instance->write('module', 'severity', 'Message from Log::Writer::File');
25
26=head1 DESCRIPTION
27
28This writer writes given messages to the simple text log file. Implementation
29is based on the Log::Writer::Handle class, see. it for more details.
30
31=head1 AUTHOR
32
33Jan Mach
34Cesnet, z.s.p.o
35jan.mach@cesnet.cz
36http://www.cesnet.cz
37
38=head1 COPYRIGHT
39
40This program is free software; you can redistribute
41it and/or modify it under the same terms as Perl itself.
42
43The full text of the license can be found in the
44LICENSE file included with this module.
45
46
47=head1 SEE ALSO
48
49perl(1), Log::Writer::Handle(3), Log::Writer::Module(3).
50
51=head1 FUNCTION REFERENCE
52
53=over 4
54
55=cut
56
57#*******************************************************************************
58#
59# INITIALIZATION AND CLEANUP SECTION
60#
61#*******************************************************************************
62
63#-- Perl core modules ---------------------------------------------------------#
64226µs282µs
# spent 47µs (12+35) within Log::Writer::File::BEGIN@64 which was called: # once (12µs+35µs) by Log::Loger::BEGIN@131 at line 64
use Carp;
# spent 47µs making 1 call to Log::Writer::File::BEGIN@64 # spent 35µs making 1 call to Exporter::import
65223µs253µs
# spent 30µs (7+23) within Log::Writer::File::BEGIN@65 which was called: # once (7µs+23µs) by Log::Loger::BEGIN@131 at line 65
use Scalar::Util 'blessed';
# spent 30µs making 1 call to Log::Writer::File::BEGIN@65 # spent 23µs making 1 call to Exporter::import
66227µs2269µs
# spent 139µs (9+130) within Log::Writer::File::BEGIN@66 which was called: # once (9µs+130µs) by Log::Loger::BEGIN@131 at line 66
use IO::File;
# spent 139µs making 1 call to Log::Writer::File::BEGIN@66 # spent 130µs making 1 call to Exporter::import
67
68#use Data::Dumper; #-+-> DEVEL ONLY <-+-#
69#use Smart::Comments; #-+-> DEVEL ONLY <-+-#
70
71#-- Perl CPAN modules ---------------------------------------------------------#
72
73#-- Custom application modules ------------------------------------------------#
74230µs14µs
# spent 4µs within Log::Writer::File::BEGIN@74 which was called: # once (4µs+0s) by Log::Loger::BEGIN@131 at line 74
use Log::Writer::Handle;
# spent 4µs making 1 call to Log::Writer::File::BEGIN@74
75
76#-- Module initializations ----------------------------------------------------#
77
# spent 10µs within Log::Writer::File::BEGIN@77 which was called: # once (10µs+0s) by Log::Loger::BEGIN@131 at line 82
BEGIN {
78242µs282µs
# spent 46µs (10+36) within Log::Writer::File::BEGIN@78 which was called: # once (10µs+36µs) by Log::Loger::BEGIN@131 at line 78
use vars qw($VERSION $DEVEL @ISA);
# spent 46µs making 1 call to Log::Writer::File::BEGIN@78 # spent 36µs making 1 call to vars::import
79310µs $VERSION = '0.01';
80 $DEVEL = 0;
81 @ISA = ('Log::Writer::Handle');
821212µs110µs}
# spent 10µs making 1 call to Log::Writer::File::BEGIN@77
83
84#-- Module clean-up code (global destructor) ----------------------------------#
8513µs
# spent 2µs within Log::Writer::File::END which was called: # once (2µs+0s) by main::RUNTIME at line 0 of mentat.storage.mongo.pl
END {
86
87}
88
89#*******************************************************************************
90#
91# CONSTANTS AND GLOBAL VARIABLES DEFINITION SECTION
92#
93#*******************************************************************************
94
95#-- Constants -----------------------------------------------------------------#
96
97#-- Static public class variables (our) ---------------------------------------#
98
99#-- Static protected class variables (my) -------------------------------------#
100
101#*******************************************************************************
102#
103# IMPLEMENTATION SECTION
104#
105#*******************************************************************************
106
107=item DESTROY [PUBLIC]
108
109 Usage : Instance destructor
110 Purpose : Close opened log file handle
111 Returns : Nothing
112 Arguments : None
113 Throws : Nothing
114
115=cut
116
117sub DESTROY {
118 my $self = shift;
119 close($self->{IO_HANDLE}) if $self->{IO_HANDLE};
120}
121
122#-------------------------------------------------------------------------------
123# Private interface
124#-------------------------------------------------------------------------------
125
126# _init [PROTECTED]
127#
128# Usage : return $self->_init(@_);
129# Purpose : Initialize the new Log::Writer::File instance
130# Arguments : STRING $log_file_name - name of the lof file
131# (for other _init arguments see Log::Writer::Handle class)
132# Returns : Log::Writer::Module reference
133# Throws : Croaks, if invoked on class, or if given invalid arguments
134# See also : Log::Writer::Handle module
135
136sub _init
137{
138 my $self = shift;
139 croak ((caller(0))[3] . ": instance method invoked on class") unless blessed($self);
140 my ($log_file_name, @arguments) = @_;
141 croak ((caller(0))[3] . ": expecting log file name to be given as argument") unless ($log_file_name);
142
143 my $io_handle = IO::File->new($log_file_name, O_WRONLY|O_APPEND|O_CREAT) or die "Can't open log file '$log_file_name': $!\n";
144 $io_handle->autoflush(1);
145 return $self->SUPER::_init($io_handle, @arguments);
146}
147
148=pod
149
150=back
151
152=cut
153
15412µs1;