NAME
HandyLog is a package that aid you logging all actions of your scripts to a
log file. Automatically gathers IP address, if used in conjunction with
HandyCGI. Automatically traces referer URLs or proxies, which forwarded
request.
SYNOPSIS
# If we would like to write into another
# log file, we should do this:
&log_set($log_filename);
&set_log_prefix('test');
&log_put('first message');
&assert(0);
In the log file this will produce something like that:
20/08/2000 22:15:00 192.168.14.4[2259]:test: first message
20/08/2000 22:15:01 192.168.14.4[2259]:test: !assert main:logtest.pl:20 sub
CONFIGURATION
- config.pm
-
We encourage you to store all your project configuration data in config
module inside of hash %cfg. All configuration for HandyCGI, HandyTemplate,
HandySQL, HandyLog, HandyMail and HandyList modules are stored in this file
by default. However, if you dislike this approach feel free to modify code
a little.
- logfname
-
Default file name for logging. Logs will be written into this file, before
log_set is called. Please, check that CGI application has permissions to
write into this file.
Default: tmp/logs/log
DESCRIPTION
- set_log_prefix($prefix)
-
Makes $prefix to be written in each log line produced by
current process.
- get_log_prefix
-
Returns current log prefix.
- log_set($filename)
-
Set alternate log filename (default is set in config.pm $cfg{'logfname'} )
- log_put($string)
-
Puts line $string into log.
- log_printf(@)
-
Just the same as log_put, but arguments similar to printf.
- error_printf(@)
-
The same as log_printf, but terminates execution of script with error code
1.
- log_hash($hash, $name)
-
Prints hash %$hash into log file line-by-line prefixing each
line with name of hash $name.
- assert($expr)
-
If $expr is true, then nothing happens. But if
$expr is false, then debug information about line, where
assertion failed is printed to log. Unlike C the program is not terminated.
Returns value of $expr.
|