NAME
Perlbug::Log - Module for generic logging/debugging functions to all Perlbug.
DESCRIPTION
Expected to be called from sub-classes, this needs some more work to cater comfortably for non-method calls.
SYNOPSIS
my $o_log = Perlbug::Log->new('log' => $log, 'res' => $res);
$o_log->append('res', "other data\n");
$o_log->append('log', "some data\n");
$o_log->append('res', "OK\n");
my $a_data = $o_log->read('res');
print $a_data; # 'other data\nOK\n'
METHODS
- new
-
Create new Perlbug::Log object
my $obj = Perlbug::Log->new('log' => $log, 'res' => $res, 'rng' => $rng, 'debug' => 2); - debug
-
Debug method, logs to "log_file", with different levels of tracking:
$pb->debug('duff usage'); # undefined second arg (treated as level 0) $pb->debug(0, 'always tracked')); # $Perlbug::Debug >= 0 $pb->debug(1, 'tracked if debug >= 1'); # key calls $pb->debug(2, 'tracked if debug >= 2'); # key calls plus data $pb->debug(3, 'tracked if debug >= 3'); # includes caller info etc. $pb->debug('in', 'args'); # in|out (2++, (data 4++)) $pb->debug('out', 'result'); # in|out, (2++, (data 4++)) - fatal
-
Deals with a fatal condition by logging and dieing, traps dies to come out here:
&do_this or $pb->fatal($message); - logg
-
Logs args to log file, which is either 'pb_19980822', or pb_backup_log. Expected to be used via "debug".
&do_this($self, 'x') and $pb->logg('Done that'); - fh
-
Define and return filehandles, keyed by 3 character string for our own purposes, otherwise the file name sitting in the system('text') dir.
$o_log->fh($file, '+>>', 0755); - append
-
Storage area (file) for results from queries, returns the FH.
my $pos = $log->append('res', 'store this stuff'); # $pos is position in file - read
-
Return the results of the queries from this session.
my $a_data = $log->read('res'); - truncate
-
Truncate this file
my $i_ok = $log->truncate('res'); - prioritise
-
Set priority nicer by given integer, or by 12.
- set_user
-
Sets the given user to the runner of this script.
- copy
-
Copy this to there
$ok = $log->copy($file1, $file2); @file1_data = $log->copy($file1, $file2); - link
-
link this to there
$ok = $log->link($source, $target, [-f]); - create
-
Create new file with this data:
$ok = $self->create("$dir/$file.tmp", $data); - syntax_check
-
Check syntax on given file
$ok = $self->syntax_check("$dir/$file.tmp"); - DESTROY
-
Cleanup log and result files.
AUTHOR
Richard Foley perlbug@rfi.net Oct 1999 2000