Log::Colorize::Helper - Makes searching and colorizing logs trivial with out all the need for piping
Version 0.1.1
use Log::Colorize::Helper; use Getopt::Std; #gets the options my %opts=(); getopts('efhtn:g:ivlFGJ', \%opts); #init it my $clog=Log::Colorize::Helper->new; #set tail/head stuff if needed if ( ! defined( $opts{n} ) ){ $opts{n}=10; } if ( $opts{t} ){ $opts{t}=$opts{n}; } if ( $opts{h} ){ $opts{h}=$opts{n}; } $clog->colorize( { echo=>$opts{e}, log=>$ARGV[0], head=>$opts{h}, tail=>$opts{t}, grep=>$opts{g}, less=>$opts{l}, follow=>$opts{f}, 'grep-insensitive'=>$opts{i}, 'grep-invert'=>$opts{v}, 'grep-first'=>$opts{F}, bzip2=>$opts{J}, gzip=>$opts{G}, } );
This module uses Error::Helper for error reporting.
Creates a new object. This method will never error.
my $clog=Log::Colorize::Helper->new;
The log is compressed using bzip2.
Print the command used.
A Perl boolean for if it should follow while tailing.
Default is false.
If set to true and tail is not specified it is set to 10.
How many lines to print at the top of the file.
The default is 0, false. This means head will not be used.
Can't be combined with tail.
An optional string to grep for.
A Perl boolean to run grep infront of the head/tail instead of after.
The default is false.
This is a Perl boolean value for if grep should be case insensitive.
This is a Perl boolean value for if grep should be inverted or not.
The log is compressed using gzip.
A Perl boolean value for if it should pass it to 'less -R'
The log file to colorize.
How many lines to print at the bottom of the file.
The default is 0, false. This means tail will not be used.
Can't be combined with head.
#gets the options my %opts=(); getopts('efhtn:g:ivlFGJ', \%opts); #init it my $clog=Log::Colorize::Helper->new; #set tail/head stuff if needed if ( ! defined( $opts{n} ) ){ $opts{n}=10; } if ( $opts{t} ){ $opts{t}=$opts{n}; } if ( $opts{h} ){ $opts{h}=$opts{n}; } $clog->colorize( { echo=>$opts{e}, log=>$ARGV[0], head=>$opts{h}, tail=>$opts{t}, grep=>$opts{g}, less=>$opts{l}, follow=>$opts{f}, 'grep-insensitive'=>$opts{i}, 'grep-invert'=>$opts{v}, 'grep-first'=>$opts{F}, bzip2=>$opts{J}, gzip=>$opts{G}, } );
No log file specified.
The log file does not exist.
A bad combination of options.
grep-first is true, but there is no grep.
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
<vvelox at vvelox.net>
Please report any bugs or feature requests to bug-log-colorize-helper at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Colorize-Helper. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-log-colorize-helper at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Log::Colorize::Helper
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Colorize-Helper
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Log-Colorize-Helper
CPAN Ratings
http://cpanratings.perl.org/d/Log-Colorize-Helper
Search CPAN
http://search.cpan.org/dist/Log-Colorize-Helper/
Copyright 2017 Zane C. Bowers-Hadley.
This program is distributed under the (Simplified) BSD License: http://www.opensource.org/licenses/BSD-2-Clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
To install Log::Colorize::Helper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Colorize::Helper
CPAN shell
perl -MCPAN -e shell install Log::Colorize::Helper
For more information on module installation, please visit the detailed CPAN module installation guide.