Filename | /usr/local/lib/site_perl/Log/Writer/File.pm |
Statements | Executed 19 statements in 418µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 13µs | 47µs | BEGIN@64 | Log::Writer::File::
1 | 1 | 1 | 11µs | 15µs | BEGIN@2 | Log::Writer::File::
1 | 1 | 1 | 9µs | 9µs | BEGIN@77 | Log::Writer::File::
1 | 1 | 1 | 8µs | 132µs | BEGIN@66 | Log::Writer::File::
1 | 1 | 1 | 7µs | 31µs | BEGIN@65 | Log::Writer::File::
1 | 1 | 1 | 7µs | 12µs | BEGIN@3 | Log::Writer::File::
1 | 1 | 1 | 6µs | 42µs | BEGIN@78 | Log::Writer::File::
1 | 1 | 1 | 4µs | 4µs | BEGIN@74 | Log::Writer::File::
1 | 1 | 1 | 2µs | 2µs | END | Log::Writer::File::
0 | 0 | 0 | 0s | 0s | DESTROY | Log::Writer::File::
0 | 0 | 0 | 0s | 0s | _init | Log::Writer::File::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Log::Writer::File; | ||||
2 | 2 | 23µs | 2 | 18µs | # spent 15µs (11+3) within Log::Writer::File::BEGIN@2 which was called:
# once (11µs+3µs) by Log::Loger::BEGIN@131 at line 2 # spent 15µs making 1 call to Log::Writer::File::BEGIN@2
# spent 3µs making 1 call to strict::import |
3 | 2 | 47µs | 2 | 17µ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 # 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 | |||||
13 | Log::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 | |||||
28 | This writer writes given messages to the simple text log file. Implementation | ||||
29 | is based on the Log::Writer::Handle class, see. it for more details. | ||||
30 | |||||
31 | =head1 AUTHOR | ||||
32 | |||||
33 | Jan Mach | ||||
34 | Cesnet, z.s.p.o | ||||
35 | jan.mach@cesnet.cz | ||||
36 | http://www.cesnet.cz | ||||
37 | |||||
38 | =head1 COPYRIGHT | ||||
39 | |||||
40 | This program is free software; you can redistribute | ||||
41 | it and/or modify it under the same terms as Perl itself. | ||||
42 | |||||
43 | The full text of the license can be found in the | ||||
44 | LICENSE file included with this module. | ||||
45 | |||||
46 | |||||
47 | =head1 SEE ALSO | ||||
48 | |||||
49 | perl(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 ---------------------------------------------------------# | ||||
64 | 2 | 28µs | 2 | 82µs | # spent 47µs (13+34) within Log::Writer::File::BEGIN@64 which was called:
# once (13µs+34µs) by Log::Loger::BEGIN@131 at line 64 # spent 47µs making 1 call to Log::Writer::File::BEGIN@64
# spent 34µs making 1 call to Exporter::import |
65 | 2 | 23µs | 2 | 54µs | # spent 31µs (7+24) within Log::Writer::File::BEGIN@65 which was called:
# once (7µs+24µs) by Log::Loger::BEGIN@131 at line 65 # spent 31µs making 1 call to Log::Writer::File::BEGIN@65
# spent 24µs making 1 call to Exporter::import |
66 | 2 | 31µs | 2 | 256µs | # spent 132µs (8+124) within Log::Writer::File::BEGIN@66 which was called:
# once (8µs+124µs) by Log::Loger::BEGIN@131 at line 66 # spent 132µs making 1 call to Log::Writer::File::BEGIN@66
# spent 124µ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 ------------------------------------------------# | ||||
74 | 2 | 28µs | 1 | 4µ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 # spent 4µs making 1 call to Log::Writer::File::BEGIN@74 |
75 | |||||
76 | #-- Module initializations ----------------------------------------------------# | ||||
77 | # spent 9µs within Log::Writer::File::BEGIN@77 which was called:
# once (9µs+0s) by Log::Loger::BEGIN@131 at line 82 | ||||
78 | 2 | 41µs | 2 | 78µs | # spent 42µs (6+36) within Log::Writer::File::BEGIN@78 which was called:
# once (6µs+36µs) by Log::Loger::BEGIN@131 at line 78 # spent 42µs making 1 call to Log::Writer::File::BEGIN@78
# spent 36µs making 1 call to vars::import |
79 | 3 | 10µs | $VERSION = '0.01'; | ||
80 | $DEVEL = 0; | ||||
81 | @ISA = ('Log::Writer::Handle'); | ||||
82 | 1 | 181µs | 1 | 9µs | } # spent 9µs making 1 call to Log::Writer::File::BEGIN@77 |
83 | |||||
84 | #-- Module clean-up code (global destructor) ----------------------------------# | ||||
85 | 1 | 3µ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 | ||
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 | |||||
117 | sub 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 | |||||
136 | sub _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 | |||||
154 | 1 | 2µs | 1; |