~ K A L I ~
UNAME : Linux web63.extendcp.co.uk 4.18.0-553.58.1.el8_10.x86_64 #1 SMP Wed Jun 25 06:37:46 EDT 2025 x86_64SERVER IP : 10.0.187.63 -________-
CLIENT IP : 216.73.216.199 MINI SHELL D ZAB '
Current File : //usr/share/perl5/HI/LazyLogger.pm |
package HI::LazyLogger;
use warnings;
#Will always attempt to log everything unless overriden with environment variable
unless ( defined $ENV{'NOLAZYLOG'} ) {
my $scriptname = $0;
#Chop off leading /
$scriptname =~ s#^/##;
#Turn path/to/script.pl into path-to-script.pl
$scriptname =~ s#/#-#mg;
my $res = open my $fh, '>>', "/var/log/${scriptname}.log";
if($res) {
#Make this the default target for print if the open succeeded
select $fh;
#Automatically add newlines
$, = "\n";
$\ = "\n";
#"Flush" so that errors and non-errors appear in the right place;
$| = 1;
print scalar(localtime), "Output from $0";
my $err = select;
close STDERR;
open STDERR, ">>/var/log/${scriptname}.log";
} else {
#Couldn't write a file, so don't change behaviour
}
}
"If music be the food of love, play on";
=head1 NAME
HI::LazyLogger - Dirty lazy way to add logging to a script
=head1 VERSION
This is the documentation of version 1.0
=head1 SYNOPSIS
use HI::LazyLogger; # This is all you have to do
=head1 DESCRIPTION
Makes /path/to/script.pl log to /var/log/path-to-script.pl.log
Changes location for all `print`, `say` and `warn` to this location
Does nothing at all if the environment variable NOLAZYLOG is set. Useful for cron.
=head1 EXAMPLES
All you need to do:
use HI::LazyLogger;
=head1 AUTHORS & ACKNOWLEDGEMENTS
Jarrod Makin E<lt>F<jmakin@godaddy.com>E<gt>
=head1 COPYRIGHT
Copyright (C) 2021 by Jarrod Makin and the GoDaddy massive.
=head1 LICENSE
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 ***BONUS***
If you're reading this, thanks for getting this far, have a lovely day
=cut
Coded by KALI :v Greetz to DR HARD ../ kali.zbi@hotmail.com