NAME

Log::Colorize::Helper - Makes searching and colorizing logs trivial with out all the need for piping

VERSION

Version 0.1.1

SYNOPSIS

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.

METHODS

new

Creates a new object. This method will never error.

my $clog=Log::Colorize::Helper->new;

colorize

args hash

bzip2

The log is compressed using bzip2.

echo

Print the command used.

follow

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.

grep

An optional string to grep for.

grep-first

A Perl boolean to run grep infront of the head/tail instead of after.

The default is false.

grep-insensitive

This is a Perl boolean value for if grep should be case insensitive.

The default is false.

grep-invert

This is a Perl boolean value for if grep should be inverted or not.

The default is false.

gzip

The log is compressed using gzip.

less

A Perl boolean value for if it should pass it to 'less -R'

log

The log file to colorize.

tail

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},
	}
	);

ERROR CODES

1/noFileSpecified

No log file specified.

2/doesNotExist

The log file does not exist.

3/badCombo

A bad combination of options.

4/noGrep

grep-first is true, but there is no grep.

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Log::Colorize::Helper

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

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.