Filename | /usr/local/lib/site_perl/Log/Writer/Std.pm |
Statements | Executed 17 statements in 353µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 13µs | 16µs | BEGIN@2 | Log::Writer::Std::
1 | 1 | 1 | 9µs | 9µs | BEGIN@75 | Log::Writer::Std::
1 | 1 | 1 | 7µs | 44µs | BEGIN@63 | Log::Writer::Std::
1 | 1 | 1 | 7µs | 29µs | BEGIN@64 | Log::Writer::Std::
1 | 1 | 1 | 6µs | 11µs | BEGIN@3 | Log::Writer::Std::
1 | 1 | 1 | 6µs | 42µs | BEGIN@76 | Log::Writer::Std::
1 | 1 | 1 | 5µs | 5µs | BEGIN@72 | Log::Writer::Std::
1 | 1 | 1 | 2µs | 2µs | END | Log::Writer::Std::
0 | 0 | 0 | 0s | 0s | _init | Log::Writer::Std::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Log::Writer::Std; | ||||
2 | 2 | 21µs | 2 | 19µs | # spent 16µs (13+3) within Log::Writer::Std::BEGIN@2 which was called:
# once (13µs+3µs) by Log::Loger::BEGIN@132 at line 2 # spent 16µs making 1 call to Log::Writer::Std::BEGIN@2
# spent 3µs making 1 call to strict::import |
3 | 2 | 54µs | 2 | 16µs | # spent 11µs (6+5) within Log::Writer::Std::BEGIN@3 which was called:
# once (6µs+5µs) by Log::Loger::BEGIN@132 at line 3 # spent 11µs making 1 call to Log::Writer::Std::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::Std - STDOUT and STDERR log writer | ||||
14 | |||||
15 | =head1 SYNOPSIS | ||||
16 | |||||
17 | use Log::Writer::Std; | ||||
18 | |||||
19 | my $writer = Log::Writer::Std->new('ERR'); | ||||
20 | my $writer = Log::Writer::Std->new('OUT',...); | ||||
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::Std'); | ||||
25 | |||||
26 | =head1 DESCRIPTION | ||||
27 | |||||
28 | This writer writes given messages to the standard output or error. | ||||
29 | |||||
30 | =head1 AUTHOR | ||||
31 | |||||
32 | Jan Mach | ||||
33 | Cesnet, z.s.p.o | ||||
34 | jan.mach@cesnet.cz | ||||
35 | http://www.cesnet.cz | ||||
36 | |||||
37 | =head1 COPYRIGHT | ||||
38 | |||||
39 | This program is free software; you can redistribute | ||||
40 | it and/or modify it under the same terms as Perl itself. | ||||
41 | |||||
42 | The full text of the license can be found in the | ||||
43 | LICENSE file included with this module. | ||||
44 | |||||
45 | |||||
46 | =head1 SEE ALSO | ||||
47 | |||||
48 | perl(1), Log::Writer::Handle(3), Log::Writer::Module(3). | ||||
49 | |||||
50 | =head1 FUNCTION REFERENCE | ||||
51 | |||||
52 | =over 4 | ||||
53 | |||||
54 | =cut | ||||
55 | |||||
56 | #******************************************************************************* | ||||
57 | # | ||||
58 | # INITIALIZATION AND CLEANUP SECTION | ||||
59 | # | ||||
60 | #******************************************************************************* | ||||
61 | |||||
62 | #-- Perl core modules ---------------------------------------------------------# | ||||
63 | 2 | 25µs | 2 | 81µs | # spent 44µs (7+37) within Log::Writer::Std::BEGIN@63 which was called:
# once (7µs+37µs) by Log::Loger::BEGIN@132 at line 63 # spent 44µs making 1 call to Log::Writer::Std::BEGIN@63
# spent 37µs making 1 call to Exporter::import |
64 | 2 | 25µs | 2 | 52µs | # spent 29µs (7+23) within Log::Writer::Std::BEGIN@64 which was called:
# once (7µs+23µs) by Log::Loger::BEGIN@132 at line 64 # spent 29µs making 1 call to Log::Writer::Std::BEGIN@64
# spent 22µs making 1 call to Exporter::import |
65 | |||||
66 | #use Data::Dumper; #-+-> DEVEL ONLY <-+-# | ||||
67 | #use Smart::Comments; #-+-> DEVEL ONLY <-+-# | ||||
68 | |||||
69 | #-- Perl CPAN modules ---------------------------------------------------------# | ||||
70 | |||||
71 | #-- Custom application modules ------------------------------------------------# | ||||
72 | 2 | 35µs | 1 | 5µs | # spent 5µs within Log::Writer::Std::BEGIN@72 which was called:
# once (5µs+0s) by Log::Loger::BEGIN@132 at line 72 # spent 5µs making 1 call to Log::Writer::Std::BEGIN@72 |
73 | |||||
74 | #-- Module initializations ----------------------------------------------------# | ||||
75 | # spent 9µs within Log::Writer::Std::BEGIN@75 which was called:
# once (9µs+0s) by Log::Loger::BEGIN@132 at line 80 | ||||
76 | 2 | 35µs | 2 | 79µs | # spent 42µs (6+36) within Log::Writer::Std::BEGIN@76 which was called:
# once (6µs+36µs) by Log::Loger::BEGIN@132 at line 76 # spent 42µs making 1 call to Log::Writer::Std::BEGIN@76
# spent 36µs making 1 call to vars::import |
77 | 3 | 9µs | $VERSION = '0.1'; | ||
78 | $DEVEL = 0; | ||||
79 | @ISA = ('Log::Writer::Handle'); | ||||
80 | 1 | 144µs | 1 | 9µs | } # spent 9µs making 1 call to Log::Writer::Std::BEGIN@75 |
81 | |||||
82 | #-- Module clean-up code (global destructor) ----------------------------------# | ||||
83 | 1 | 3µs | # spent 2µs within Log::Writer::Std::END which was called:
# once (2µs+0s) by main::RUNTIME at line 0 of mentat.storage.mongo.pl | ||
84 | |||||
85 | } | ||||
86 | |||||
87 | #******************************************************************************* | ||||
88 | # | ||||
89 | # CONSTANTS AND GLOBAL VARIABLES DEFINITION SECTION | ||||
90 | # | ||||
91 | #******************************************************************************* | ||||
92 | |||||
93 | #-- Constants -----------------------------------------------------------------# | ||||
94 | |||||
95 | #-- Static public class variables (our) ---------------------------------------# | ||||
96 | |||||
97 | #-- Static protected class variables (my) -------------------------------------# | ||||
98 | |||||
99 | #******************************************************************************* | ||||
100 | # | ||||
101 | # IMPLEMENTATION SECTION | ||||
102 | # | ||||
103 | #******************************************************************************* | ||||
104 | |||||
105 | #------------------------------------------------------------------------------- | ||||
106 | # Private interface | ||||
107 | #------------------------------------------------------------------------------- | ||||
108 | |||||
109 | # _init [PROTECTED] | ||||
110 | # | ||||
111 | # Usage : return $self->_init(@_); | ||||
112 | # Purpose : Initialize the new Log::Writer::Std instance | ||||
113 | # Arguments : ENUM $type - type of output (OUT|ERR) | ||||
114 | # (for other _init arguments see Log::Writer::Handle class) | ||||
115 | # Returns : Log::Writer::Module reference | ||||
116 | # Throws : Croaks, if invoked on class, or if given invalid arguments | ||||
117 | # See also : Log::Writer::Handle module | ||||
118 | |||||
119 | sub _init | ||||
120 | { | ||||
121 | my $self = shift; | ||||
122 | croak ((caller(0))[3] . ": instance method invoked on class") unless blessed($self); | ||||
123 | my ($type, @arguments) = @_; | ||||
124 | |||||
125 | my $handle_std = (defined($type) and uc($type) eq 'OUT') ? fileno(STDOUT) : fileno(STDERR); | ||||
126 | my $io_handle = IO::Handle->new_from_fd($handle_std, "w") or die "Can't open terminal output '$type': $!\n"; | ||||
127 | return $self->SUPER::_init($io_handle, @arguments); | ||||
128 | } | ||||
129 | |||||
130 | =pod | ||||
131 | |||||
132 | =back | ||||
133 | |||||
134 | =cut | ||||
135 | |||||
136 | 1 | 2µs | 1; |