• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

samples/H07-Jul-2006-18769

t/H07-Jul-2006-6341

ChangesH A D07-Jul-2006996 2918

MANIFESTH A D07-Jul-2006198 1312

META.ymlH A D07-Jul-2006429 1412

Makefile.PLH A D07-Jul-2006776 2118

READMEH A D07-Jul-20064.9 KiB154110

Toolkit.pmH A D07-Jul-200612.2 KiB508281

README

1NAME
2    IO::Toolkit
3
4ABSTRACT
5    IO::Toolkit - Perl extension to create logfiles
6
7PREREQUISITS
8    This module needs Crypt::RC6 for its encryption/decryption routine.
9    Digest::MD5 and DirHandle used for checksum routines.
10
11SYNOPSIS
12    Sample Script (please also have a look into the samples directory):
13
14       use IO::Toolkit;
15       use File::Basename;
16
17       package main;
18       use vars qw($getopt_loglevel $program $programname);
19
20       my $program = basename($0);
21       $programname = $program;
22       $programname =~ s/\.pl//g;
23
24       my $logfilename = $programname . ".log";
25       my $VERSION = sprintf "%d.%05d", '$Revision: 8 $' =~ /(\d+)/g;
26       my $description = "Script";
27
28       my $extra;
29       my @extra_options = (
30                            {
31                                    Spec            =>  "extra=s",
32                                    Variable        => \$extra,
33                                    Help            => "--extra=whatever",
34                                    Verbose         => ["--extra=whatever",
35                                                        "whatever whenever...",
36                                                       ]
37                            },
38                        );
39
40       IO::Toolkit::commandline(@extra_options);
41
42       logme("open", $logfilename);
43       logme("M","$programname V$VERSION started --------------------------------------------------");
44       logme("C", "Logfile $logfilename used.");
45       logme("M","$programname V$VERSION ended   --------------------------------------------------");
46       logme("close");
47
48    This displays and creates a logfile like this:
49
50       2004-11-14 13:07:48 [mytemplate] <M> mytemplate V1.00004 started --------------------------------------------------
51       2004-11-14 13:07:48 [mytemplate] <C> Logfile mytemplate.log used.
52       2004-11-14 13:07:48 [mytemplate] <M> mytemplate V1.00004 ended   --------------------------------------------------
53
54IMPORTANT NOTICE
55    If you are looking for a better logging-module, please check Log4Perl
56    instead.
57
58DESCRIPTION
59    Provides a human-readable logfile and is ment to replace "print" and
60    "die" in your programs.
61
62    This module was written to provide an easy way to log messages. It
63    checks for an option --loglevel=EMCDQ- where each character stands for a
64    certain level. e.g.
65
66       E   = Error
67       S   = System
68       M   = Message
69       D   = Debug
70       -   = Silent
71       all = All messages
72
73    You can use all characters you would like to use. These are just
74    examples.
75
76    the minus ("-") has a special meaning: supresses output to the screen
77    and ONLY logs them to the file. Please see the sample script for more
78    details.
79
80    The function gettimestamp returns the current time in the format used
81    for the logfile. If you specifiy the format &gettimestamp("filename") it
82    returns something like this: 20041009131500
83
84  IO::Toolkit::logme("M","Message")
85    The first parameter specifies the severity of the message. The message
86    is only logged, if $getopt_loglevel contains that severity.
87
88    Because IO::Toolkit::logme is exported, you can just use
89    logme("M","message") in your scripts.
90
91  IO::Toolkit::moduleinfo
92    prints a list of loaded modules.
93
94  IO::Toolkit::trim
95    trims a variable.
96
97  IO::Toolkit::hash2sql
98    creates SQL code to insert a hash into a table.
99
100    Example:
101
102       use IO::Toolkit;
103
104       my %hash=(
105          firstname=>"Markus",
106          lastname=>"Linke",
107       );
108
109       print IO::Toolkit::hash2sqlinsert("tablename",%hash)."\n";
110
111    Result:
112
113       insert into tablename (firstname,lastname) values ("Markus","Linke")
114
115    IO::Toolkit::sql2data executes SQL statement and creates a array of
116    hashs
117
118       use IO::Toolkit;
119       use Data::Dumper;
120       print Dumper(IO::Toolkit::sql2data($dbh,"select * from environments"));
121
122  IO::Toolkit::encrypt and IO::Toolkit::decrypt
123    needs two strings as parameters (e.g. seed and password) and returns an
124    encrypted/decrypted value.
125
126  IO::Toolkit::pid("exclusive|overwrite|remove","/tmp/filename.pid");
127    Create or delete PID file. If set to exclusive, the program dies if the
128    file already exists.
129
130  my $md5 = IO::Toolkit::get_md5_checksum("Toolkit.pm");
131    Create a MD5 checksum for the filename provided.
132
133EXPORT
134    logme and gettimestamp are exported.
135
136SEE ALSO
137       http://www.linke.de for my personal homepage and
138       http://trac.it-projects.com/iotoolkit for the project TRAC pages
139
140       Please submit bugs at http://bugzilla.it-projects.com
141
142       Hosted Subversion Version Control provided by http://svn.it-projects.com
143       Checkout the latest version at https://svn.it-projects.com/svn/iotoolkit
144
145AUTHOR
146    Markus Linke, markus.linke@linke.de
147
148COPYRIGHT AND LICENSE
149    Copyright 2003-2006 by Markus Linke
150
151    This library is free software; you can redistribute it and/or modify it
152    under the same terms as Perl itself.
153
154