GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Toolkit(3) User Contributed Perl Documentation Toolkit(3)

IO::Toolkit

IO::Toolkit - Perl extension to create logfiles

This module needs Crypt::RC6 for its encryption/decryption routine. Digest::MD5 and DirHandle used for checksum routines.

Sample Script (please also have a look into the samples directory):

   use IO::Toolkit;
   use File::Basename;

   package main;
   use vars qw($getopt_loglevel $program $programname);

   my $program = basename($0);    
   $programname = $program;
   $programname =~ s/\.pl//g;

   my $logfilename = $programname . ".log";
   my $VERSION = sprintf "%d.%05d", '$Revision: 8 $' =~ /(\d+)/g;
   my $description = "Script";

   my $extra;
   my @extra_options = (
                        { 
                                Spec            =>  "extra=s",
                                Variable        => \$extra,
                                Help            => "--extra=whatever",
                                Verbose         => ["--extra=whatever",
                                                    "whatever whenever...",
                                                   ] 
                        },
                    );
                
   IO::Toolkit::commandline(@extra_options);

   logme("open", $logfilename);
   logme("M","$programname V$VERSION started --------------------------------------------------");
   logme("C", "Logfile $logfilename used.");
   logme("M","$programname V$VERSION ended   --------------------------------------------------");
   logme("close");

This displays and creates a logfile like this:

   2004-11-14 13:07:48 [mytemplate] <M> mytemplate V1.00004 started --------------------------------------------------
   2004-11-14 13:07:48 [mytemplate] <C> Logfile mytemplate.log used.
   2004-11-14 13:07:48 [mytemplate] <M> mytemplate V1.00004 ended   --------------------------------------------------

If you are looking for a better logging-module, please check Log4Perl instead.

Provides a human-readable logfile and is ment to replace "print" and "die" in your programs.

This module was written to provide an easy way to log messages. It checks for an option --loglevel=EMCDQ- where each character stands for a certain level. e.g.

   E   = Error
   S   = System
   M   = Message
   D   = Debug
   -   = Silent
   all = All messages

You can use all characters you would like to use. These are just examples.

the minus ("-") has a special meaning: supresses output to the screen and ONLY logs them to the file. Please see the sample script for more details.

The function gettimestamp returns the current time in the format used for the logfile. If you specifiy the format &gettimestamp("filename") it returns something like this: 20041009131500

The first parameter specifies the severity of the message. The message is only logged, if $getopt_loglevel contains that severity.

Because IO::Toolkit::logme is exported, you can just use logme("M","message") in your scripts.

prints a list of loaded modules.

trims a variable.

creates SQL code to insert a hash into a table.

Example:

   use IO::Toolkit;

   my %hash=(
      firstname=>"Markus",
      lastname=>"Linke",
   );

   print IO::Toolkit::hash2sqlinsert("tablename",%hash)."\n";

Result:

   insert into tablename (firstname,lastname) values ("Markus","Linke")

IO::Toolkit::sql2data executes SQL statement and creates a array of hashs

   use IO::Toolkit;
   use Data::Dumper;
   print Dumper(IO::Toolkit::sql2data($dbh,"select * from environments"));

needs two strings as parameters (e.g. seed and password) and returns an encrypted/decrypted value.

Create or delete PID file. If set to exclusive, the program dies if the file already exists.

Create a MD5 checksum for the filename provided.

logme and gettimestamp are exported.

   http://www.linke.de for my personal homepage and
   http://trac.it-projects.com/iotoolkit for the project TRAC pages
   
   Please submit bugs at http://bugzilla.it-projects.com
   
   Hosted Subversion Version Control provided by http://svn.it-projects.com
   Checkout the latest version at https://svn.it-projects.com/svn/iotoolkit

Markus Linke, markus.linke@linke.de

Copyright 2003-2006 by Markus Linke

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2006-07-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.