| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Colorize::Helper; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
47032
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
31
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'Error::Helper'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
369
|
|
|
7
|
1
|
|
|
1
|
|
839
|
use String::ShellQuote; |
|
|
1
|
|
|
|
|
790
|
|
|
|
1
|
|
|
|
|
639
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Log::Colorize::Helper - Makes searching and colorizing logs trivial with out all the need for piping |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.0.0 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.0.0'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Log::Colorize::Helper; |
|
25
|
|
|
|
|
|
|
use Getopt::Std; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#gets the options |
|
28
|
|
|
|
|
|
|
my %opts=(); |
|
29
|
|
|
|
|
|
|
getopts('efhtn:g:ivlFGJ', \%opts); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#init it |
|
32
|
|
|
|
|
|
|
my $clog=Log::Colorize::Helper->new; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#set tail/head stuff if needed |
|
35
|
|
|
|
|
|
|
if ( ! defined( $opts{n} ) ){ |
|
36
|
|
|
|
|
|
|
$opts{n}=10; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
if ( $opts{t} ){ |
|
39
|
|
|
|
|
|
|
$opts{t}=$opts{n}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
if ( $opts{h} ){ |
|
42
|
|
|
|
|
|
|
$opts{h}=$opts{n}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$clog->colorize( |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
|
|
|
|
|
|
echo=>$opts{e}, |
|
48
|
|
|
|
|
|
|
log=>$ARGV[0], |
|
49
|
|
|
|
|
|
|
head=>$opts{h}, |
|
50
|
|
|
|
|
|
|
tail=>$opts{t}, |
|
51
|
|
|
|
|
|
|
grep=>$opts{g}, |
|
52
|
|
|
|
|
|
|
less=>$opts{l}, |
|
53
|
|
|
|
|
|
|
follow=>$opts{f}, |
|
54
|
|
|
|
|
|
|
'grep-insensitive'=>$opts{i}, |
|
55
|
|
|
|
|
|
|
'grep-invert'=>$opts{v}, |
|
56
|
|
|
|
|
|
|
'grep-first'=>$opts{F}, |
|
57
|
|
|
|
|
|
|
bzip2=>$opts{J}, |
|
58
|
|
|
|
|
|
|
gzip=>$opts{G}, |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This module uses L for error reporting. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 new |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Creates a new object. This method will never error. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $clog=Log::Colorize::Helper->new; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new { |
|
75
|
0
|
|
|
0
|
1
|
|
my $self={ |
|
76
|
|
|
|
|
|
|
perror=>undef, |
|
77
|
|
|
|
|
|
|
error=>undef, |
|
78
|
|
|
|
|
|
|
errorString=>'', |
|
79
|
|
|
|
|
|
|
errorExtra=>{ |
|
80
|
|
|
|
|
|
|
flags=>{ |
|
81
|
|
|
|
|
|
|
1=>'noFileSpecified', |
|
82
|
|
|
|
|
|
|
2=>'doesNotExist', |
|
83
|
|
|
|
|
|
|
3=>'badCombo', |
|
84
|
|
|
|
|
|
|
4=>'noGre[', |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
|
|
|
|
|
|
}, |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
0
|
|
|
|
|
|
bless $self; |
|
89
|
0
|
|
|
|
|
|
return $self; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 colorize |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 args hash |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head4 bzip2 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The log is compressed using bzip2. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head4 echo |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Print the command used. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head4 follow |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
A Perl boolean for if it should follow while tailing. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Default is false. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
If set to true and tail is not specified it is set to 10. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head4 head |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
How many lines to print at the top of the file. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The default is 0, false. This means head will not be used. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Can't be combined with tail. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head4 grep |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
An optional string to grep for. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head4 grep-first |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
A Perl boolean to run grep infront of the head/tail instead of after. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The default is false. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head4 grep-insensitive |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This is a Perl boolean value for if grep should be case insensitive. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The default is false. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head4 grep-invert |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is a Perl boolean value for if grep should be inverted or not. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The default is false. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head4 gzip |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
The log is compressed using gzip. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head4 less |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
A Perl boolean value for if it should pass it to 'less -R' |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head4 log |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The log file to colorize. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head4 tail |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
How many lines to print at the bottom of the file. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The default is 0, false. This means tail will not be used. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Can't be combined with head. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
#gets the options |
|
163
|
|
|
|
|
|
|
my %opts=(); |
|
164
|
|
|
|
|
|
|
getopts('efhtn:g:ivlFGJ', \%opts); |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
#init it |
|
167
|
|
|
|
|
|
|
my $clog=Log::Colorize::Helper->new; |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
#set tail/head stuff if needed |
|
170
|
|
|
|
|
|
|
if ( ! defined( $opts{n} ) ){ |
|
171
|
|
|
|
|
|
|
$opts{n}=10; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
if ( $opts{t} ){ |
|
174
|
|
|
|
|
|
|
$opts{t}=$opts{n}; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
if ( $opts{h} ){ |
|
177
|
|
|
|
|
|
|
$opts{h}=$opts{n}; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$clog->colorize( |
|
181
|
|
|
|
|
|
|
{ |
|
182
|
|
|
|
|
|
|
echo=>$opts{e}, |
|
183
|
|
|
|
|
|
|
log=>$ARGV[0], |
|
184
|
|
|
|
|
|
|
head=>$opts{h}, |
|
185
|
|
|
|
|
|
|
tail=>$opts{t}, |
|
186
|
|
|
|
|
|
|
grep=>$opts{g}, |
|
187
|
|
|
|
|
|
|
less=>$opts{l}, |
|
188
|
|
|
|
|
|
|
follow=>$opts{f}, |
|
189
|
|
|
|
|
|
|
'grep-insensitive'=>$opts{i}, |
|
190
|
|
|
|
|
|
|
'grep-invert'=>$opts{v}, |
|
191
|
|
|
|
|
|
|
'grep-first'=>$opts{F}, |
|
192
|
|
|
|
|
|
|
bzip2=>$opts{J}, |
|
193
|
|
|
|
|
|
|
gzip=>$opts{G}, |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
); |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub colorize{ |
|
201
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
202
|
0
|
|
|
|
|
|
my %args; |
|
203
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
|
204
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
|
0
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$self->errorblank; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
#set various defaults |
|
210
|
0
|
0
|
|
|
|
|
if ( !defined( $args{head} ) ){ |
|
211
|
0
|
|
|
|
|
|
$args{head}=0; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
0
|
0
|
|
|
|
|
if ( !defined( $args{echo} ) ){ |
|
214
|
0
|
|
|
|
|
|
$args{echo}=0; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
0
|
0
|
|
|
|
|
if ( !defined( $args{tail} ) ){ |
|
217
|
0
|
|
|
|
|
|
$args{tail}=0; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
0
|
0
|
|
|
|
|
if ( !defined( $args{less} ) ){ |
|
220
|
0
|
|
|
|
|
|
$args{less}=0; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
0
|
0
|
|
|
|
|
if ( !defined( $args{bzip2} ) ){ |
|
223
|
0
|
|
|
|
|
|
$args{bzip2}=0; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
0
|
0
|
|
|
|
|
if ( !defined( $args{gzip} ) ){ |
|
226
|
0
|
|
|
|
|
|
$args{gzip}=0; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
0
|
0
|
|
|
|
|
if ( !defined( $args{'grep-first'} ) ){ |
|
229
|
0
|
|
|
|
|
|
$args{'grep-first'}=0; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
0
|
0
|
|
|
|
|
if ( !defined( $args{'grep-insensitive'} ) ){ |
|
232
|
0
|
|
|
|
|
|
$args{'grep-insensitive'}=0; |
|
233
|
|
|
|
|
|
|
} |
|
234
|
0
|
0
|
|
|
|
|
if ( !defined( $args{'grep-invert'} ) ){ |
|
235
|
0
|
|
|
|
|
|
$args{'grep-invert'}=0; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
#set tail to 10 if it is not set and follow is set |
|
239
|
0
|
0
|
0
|
|
|
|
if ( $args{follow} && ! $args{tail} ){ |
|
240
|
0
|
|
|
|
|
|
$args{tail}=10; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#error if grep is not set and follow is true |
|
244
|
0
|
0
|
0
|
|
|
|
if ( $args{'grep-first'} && ! defined( $args{grep} ) ){ |
|
245
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
246
|
0
|
|
|
|
|
|
$self->{errorString}='grep-first is true, but grep is not set'; |
|
247
|
0
|
|
|
|
|
|
$self->warn; |
|
248
|
0
|
|
|
|
|
|
return undef; |
|
249
|
|
|
|
|
|
|
} |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
#cam't combine these both tail and head |
|
252
|
0
|
0
|
|
|
|
|
if ( $args{head} & $args{tail} ){ |
|
253
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
254
|
0
|
|
|
|
|
|
$self->{errorString}="Can't combine head and tail"; |
|
255
|
0
|
|
|
|
|
|
$self->warn; |
|
256
|
0
|
|
|
|
|
|
return undef; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
#can't combine follow and head |
|
260
|
0
|
0
|
0
|
|
|
|
if ( $args{head} && $args{follow} ){ |
|
261
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
262
|
0
|
|
|
|
|
|
$self->{errorString}="Can't combine head and follow"; |
|
263
|
0
|
|
|
|
|
|
$self->warn; |
|
264
|
0
|
|
|
|
|
|
return undef; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
#can't combine follow and head |
|
268
|
0
|
0
|
0
|
|
|
|
if ( $args{'grep-first'} && $args{follow} ){ |
|
269
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
270
|
0
|
|
|
|
|
|
$self->{errorString}="Can't combine follow and grep first"; |
|
271
|
0
|
|
|
|
|
|
$self->warn; |
|
272
|
0
|
|
|
|
|
|
return undef; |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#make sure we have a log specified |
|
276
|
0
|
0
|
|
|
|
|
if ( !defined( $args{log} ) ){ |
|
277
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
278
|
0
|
|
|
|
|
|
$self->{errorString}='no log file specified'; |
|
279
|
0
|
|
|
|
|
|
$self->warn; |
|
280
|
0
|
|
|
|
|
|
return undef; |
|
281
|
|
|
|
|
|
|
}; |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
#make sure it exists and is a file |
|
284
|
0
|
0
|
|
|
|
|
if ( ! -f $args{log} ){ |
|
285
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
286
|
0
|
|
|
|
|
|
$self->{errorString}='"'.$args{log}.'" is not a file or does not exist'; |
|
287
|
0
|
|
|
|
|
|
$self->warn; |
|
288
|
0
|
|
|
|
|
|
return undef; |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
#the command to use, initial assembly |
|
292
|
0
|
|
|
|
|
|
my $command='cat '.shell_quote( $args{log} ).' '; |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
#unarchive if needed... |
|
295
|
0
|
0
|
|
|
|
|
if ( $args{bzip2} ){ |
|
296
|
0
|
|
|
|
|
|
$command=$command.'| bunzip2 '; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
0
|
0
|
|
|
|
|
if ( $args{gzip} ){ |
|
299
|
0
|
|
|
|
|
|
$command=$command.'| gunzip '; |
|
300
|
|
|
|
|
|
|
} |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
#puts grep together |
|
303
|
0
|
|
|
|
|
|
my $grep=''; |
|
304
|
0
|
0
|
|
|
|
|
if ( defined( $args{grep} ) ){ |
|
305
|
0
|
|
|
|
|
|
$grep='| grep'; |
|
306
|
|
|
|
|
|
|
|
|
307
|
0
|
0
|
|
|
|
|
if ( $args{'grep-insensitive'} ){ |
|
308
|
0
|
|
|
|
|
|
$grep=$grep.' -i'; |
|
309
|
|
|
|
|
|
|
} |
|
310
|
0
|
0
|
|
|
|
|
if ( $args{'grep-insensitive'} ){ |
|
311
|
0
|
|
|
|
|
|
$grep=$grep.' -v'; |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
#unarchive if needed |
|
315
|
0
|
0
|
0
|
|
|
|
if ( $args{'grep-first'} && $args{bzip2} ){ |
|
316
|
0
|
|
|
|
|
|
$grep=$grep.' -J'; |
|
317
|
|
|
|
|
|
|
} |
|
318
|
0
|
0
|
0
|
|
|
|
if ( $args{'grep-first'} && $args{gzip} ){ |
|
319
|
0
|
|
|
|
|
|
$grep=$grep.' -Z'; |
|
320
|
|
|
|
|
|
|
} |
|
321
|
|
|
|
|
|
|
|
|
322
|
0
|
|
|
|
|
|
$grep=$grep.' '.$args{grep}; |
|
323
|
|
|
|
|
|
|
} |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
#apply grep if it is first |
|
326
|
0
|
0
|
|
|
|
|
if ( $args{'grep-first'} ){ |
|
327
|
0
|
|
|
|
|
|
$command=$grep.' '.shell_quote( $args{log} ).' '; |
|
328
|
0
|
|
|
|
|
|
$grep=''; #blank grep so when we apply it we are not running it twice |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
#add head if needed |
|
332
|
0
|
0
|
|
|
|
|
if ( $args{head} ){ |
|
333
|
0
|
|
|
|
|
|
$command=$command.'| head -n '.$args{head}.' '; |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
#tail if needed |
|
337
|
0
|
0
|
|
|
|
|
if ( $args{tail} ){ |
|
338
|
0
|
0
|
|
|
|
|
if ( $args{follow} ){ |
|
339
|
0
|
|
|
|
|
|
$command='tail -f -n '.$args{tail}.' '.shell_quote( $args{log} ).' '; |
|
340
|
|
|
|
|
|
|
}else{ |
|
341
|
0
|
|
|
|
|
|
$command=$command.'| tail -n '.$args{tail}; |
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
} |
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
#add grep and colorize |
|
346
|
0
|
|
|
|
|
|
$command=$command.$grep.' | colorize'; |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
#add less if desired |
|
349
|
0
|
0
|
|
|
|
|
if ( $args{less} ){ |
|
350
|
0
|
|
|
|
|
|
$command=$command.' | less -R'; |
|
351
|
|
|
|
|
|
|
} |
|
352
|
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
#echo if needed |
|
354
|
0
|
0
|
|
|
|
|
if ( $args{echo} ){ |
|
355
|
0
|
|
|
|
|
|
print $command."\n"; |
|
356
|
|
|
|
|
|
|
} |
|
357
|
|
|
|
|
|
|
|
|
358
|
0
|
|
|
|
|
|
system($command); |
|
359
|
|
|
|
|
|
|
|
|
360
|
0
|
|
|
|
|
|
return 1; |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=head2 1/noFileSpecified |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
No log file specified. |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=head2 2/doesNotExist |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
The log file does not exist. |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=head2 3/badCombo |
|
374
|
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
A bad combination of options. |
|
376
|
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head2 4/noGrep |
|
378
|
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
grep-first is true, but there is no grep. |
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head1 AUTHOR |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=head1 BUGS |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
388
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
389
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=head1 SUPPORT |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
perldoc Log::Colorize::Helper |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
You can also look for information at: |
|
402
|
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=over 4 |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
406
|
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
L |
|
408
|
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
L |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
414
|
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
L |
|
416
|
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
=item * Search CPAN |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
L |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=back |
|
422
|
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
425
|
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
Copyright 2017 Zane C. Bowers-Hadley. |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
This program is distributed under the (Simplified) BSD License: |
|
432
|
|
|
|
|
|
|
L |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without |
|
435
|
|
|
|
|
|
|
modification, are permitted provided that the following conditions |
|
436
|
|
|
|
|
|
|
are met: |
|
437
|
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright |
|
439
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer. |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright |
|
442
|
|
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the |
|
443
|
|
|
|
|
|
|
documentation and/or other materials provided with the distribution. |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
446
|
|
|
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
447
|
|
|
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
448
|
|
|
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
449
|
|
|
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
450
|
|
|
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
451
|
|
|
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
452
|
|
|
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
453
|
|
|
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
454
|
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
455
|
|
|
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=cut |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
1; # End of Log::Colorize::Helper |