Name : perl-Log-Logger
| |
Version : 1.01
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.6.1
| Date : 2023-07-20 18:15:36
|
Group : Development/Libraries/Perl
| Source RPM : perl-Log-Logger-1.01-lp155.6.1.src.rpm
|
Size : 0.01 MB
| |
Packager : https://www_suse_com/
| |
Summary : OO interface to user defined logfile
|
Description :
Whenever writing scripts for system management, I always find myself wishing to keep a log of what I have done. But typing
print LOGHANDLE $progname . \": \" . $stringToLog . \"\ \";
every time gets really old. Similarly, \'die()\' does not have the facility to print to a logfile as it exits.
A long time ago, I wrote two functions, \'log()\' and \'fail()\', to handle this problem. I cut and pasted them everywhere. But now that Perl does modules for object reuse, I have ported them to a module and added features.
\'Log::Logger\' is esentially a wrapper around an \'IO::File\' object. The \'open\' and \'open_append\' functions just call \'IO::File->open()\' with the appropriate arguments. The useful functionality is in the \'log()\', \'log_print()\', and \'fail()\' methods. These methods make logging what you are doing -- and printing to the user, if you like -- one line of code. eg:
print STDOUT \"$progName: Running /var/clean script...\ \"; print LOGHANDLE \"$progName: Running /var/clean script...\ \";
$lh->log_print(\"Running /var/clean script...\");
And if you wish to log things, but also keep neat die() expressions, you can. eg:
system(\"foo\") == 0 or die \"Call to foo failed\"
system(\"foo\") == 0 or do { print LOGHANDLE, \"Call to foo failed\"; die \"Call to foo failed\"; }
system(\"foo\") == 0 or $lh->fail(\"Call to foo failed\");
Obviously, this is not a huge difference, but in a utility where you keep track of a lot of operations, it just is easier, and saves a little bit of typing. Remember, one of the fundamental qualities of a programmer is Laziness (see the Camel book).
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-L/15.5/noarch |