line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
85700
|
use 5.006; # our |
|
4
|
|
|
|
|
10
|
|
2
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
93
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
196
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Acme::Beamerang::Logger; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001000'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1518
|
use parent 'Log::Contextual'; |
|
4
|
|
|
|
|
974
|
|
|
4
|
|
|
|
|
15
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
0
|
148287
|
sub default_import { qw(:dlog :log ) } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# This ideally would be regulated by the importing class |
14
|
|
|
|
|
|
|
# but I got tired of trying to guess what horrible magic |
15
|
|
|
|
|
|
|
# was necessary to make Exporter::Declare and whatever |
16
|
|
|
|
|
|
|
# the hell Log::Contextual's import logic does work. |
17
|
|
|
|
|
|
|
sub _get_prefixes { |
18
|
4
|
|
|
4
|
|
5
|
my $class = $_[0]; |
19
|
4
|
|
|
|
|
18
|
my (@parts) = split /::/sx, $class; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Always assume there is no Acme |
22
|
|
|
|
|
|
|
# Acme::X is X in the future. |
23
|
4
|
100
|
|
|
|
13
|
shift @parts if $parts[0] eq 'Acme'; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
6
|
my (@prefixes); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Always include FQ name, sans Acme |
28
|
4
|
|
|
|
|
13
|
push @prefixes, uc( join q/_/, @parts ); |
29
|
4
|
|
|
|
|
8
|
pop @parts; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# If its a Beamerang subclass, split the namespace |
32
|
|
|
|
|
|
|
# and create env vars for each level. |
33
|
4
|
100
|
66
|
|
|
28
|
if ( 2 <= @parts and ( 'Beamerang' eq shift @parts ) ) { |
34
|
2
|
|
|
|
|
4
|
while (@parts) { |
35
|
2
|
|
|
|
|
12
|
push @prefixes, uc( join q/_/, 'BEAMERANG', @parts ); |
36
|
2
|
|
|
|
|
6
|
pop @parts; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
4
|
|
|
|
|
11
|
return @prefixes, 'BEAMERANG'; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub arg_default_logger { |
43
|
4
|
50
|
|
4
|
0
|
4327
|
return $_[1] if $_[1]; |
44
|
4
|
|
|
|
|
2012
|
require Log::Contextual::WarnLogger::Fancy; |
45
|
4
|
|
|
|
|
5163
|
my $caller = caller(3); |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
16
|
my ( $env, @group ) = _get_prefixes($caller); |
48
|
4
|
|
|
|
|
52
|
return Log::Contextual::WarnLogger::Fancy->new( |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
env_prefix => $env, |
51
|
|
|
|
|
|
|
group_env_prefix => \@group, |
52
|
|
|
|
|
|
|
label => $caller, |
53
|
|
|
|
|
|
|
label_length => 21, |
54
|
|
|
|
|
|
|
default_upto => 'warn', |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Acme::Beamerang::Logger - A Simple per-class clan warnlogger loader |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Interface is basically the same as Log::Contextual::Easy::Default |
68
|
|
|
|
|
|
|
use Acme::Beamerang::Logger; # imports :dlog and :log by default |
69
|
|
|
|
|
|
|
# also assigns a default logger to the package. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This class is a convenience layer to tie L |
74
|
|
|
|
|
|
|
into the C project space. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is very experiemental and is a research project ( hence C ). |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This would otherwise be part of the other C things that are still yet to |
79
|
|
|
|
|
|
|
materialise, but the inversion control this project entails means directly coupling |
80
|
|
|
|
|
|
|
this component with either of those parts would lead to a dependency graph that would |
81
|
|
|
|
|
|
|
defeat the point of the control inversion. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This tool otherwise loads up C with a nice default logger, with all the glue |
84
|
|
|
|
|
|
|
in place to be convenient for this project, while still having an open door to a real logger. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ENVIRONMENT |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This module utilizes the C and C of L |
89
|
|
|
|
|
|
|
to generate a collection of C vars for narrow or broad incision of logging statements without need |
90
|
|
|
|
|
|
|
to use more complex logging technology. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Every package that uses this logger will respond to C and C values. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Every package beginning with either C or C will additionally respond to |
95
|
|
|
|
|
|
|
a collection of namespace oriented C variables. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
For instance, |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Acme::Beamerang::Foo::Bar::Baz |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Will respond to any of the following C vars: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
BEAMERANG_FOO_BAR_BAZ_$LEVEL |
104
|
|
|
|
|
|
|
BEAMERANG_FOO_BAR_$LEVEL |
105
|
|
|
|
|
|
|
BEAMERANG_FOO_$LEVEL |
106
|
|
|
|
|
|
|
BEAMERANG_$LEVEL |
107
|
|
|
|
|
|
|
BEAMERNAG_FOO_BAR_BAZ_UPTO |
108
|
|
|
|
|
|
|
BEAMERANG_FOO_BAR_UPTO |
109
|
|
|
|
|
|
|
BEAMERANG_FOO_UPTO |
110
|
|
|
|
|
|
|
BEAMERANG_UPTO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This means you can turn on debugging for as much, or as little as you like, without |
113
|
|
|
|
|
|
|
having to radically change the code. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 NAMING |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 Acme |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Firstly, this is named C, because its a bunch of bad ideas glued together, and I |
120
|
|
|
|
|
|
|
don't want people to use this until its "ready", but I'm going to need to use it lots before I get comfortable |
121
|
|
|
|
|
|
|
anything right is done. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
When its ready (if ever), it will ship as C ... maybe. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 Beamerang |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This is my dumb joke based on C, which this compontent is going to end up being used in conjunction with. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
I thought at first C -> C, but then that was too high level. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
And then I thought C .... but eh, I didn't like that either. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
So C is a mutant hybrid of the above. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Other parts of this system that have yet to manifest will use the same convention. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SEE ALSO |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * L<< C|Log::Contextual::Easy::Default >> - Interface is otherwise identical to this |
142
|
|
|
|
|
|
|
module, only the default logger in choice and its configuration differs. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=back |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Kent Fredric |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 LICENSE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Kent Fredric. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the |
155
|
|
|
|
|
|
|
same terms as the Perl 5 programming language system itself. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |