| Perlbug documentation | view source | Contained in the Perlbug distribution. |
Perlbug::Log - Module for generic logging/debugging functions to all Perlbug.
Expected to be called from sub-classes, this needs some more work to cater comfortably for non-method calls.
Debug level can be modified via the environment variable: Perlbug_Debug
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'
Create new Perlbug::Log object
my $obj = Perlbug::Log->new('log' => $log, 'tmp => $tmp, 'debug' => 2);
Return files based on key (or all)
my @files = $o_log->files();
Return handle based on key
my $fh = $o_log->handle('log');
Cleanup log and tmp files.
This is in flux at the moment, please be warned!
Debug method, logs to log_file, with configurable levels of tracking:
Controlled by $ENV{'Perlbug_Debug'} || $Perlbug::Debug
> 0 = login, object, function (basic) 1 = decisions (sets x) 2 = data feedback from within methods (sets i, x, X) 3 = more than you want (sets C, I, s, S, O, X)
# a = AUTOLOAD methods
# c = print to STDOUT as it goes (good for command-line debugging)
# C = Carp to STDERR as it goes (with caller)
m = method names
M = Method names with package data
s = sql statements (num rows affected)
S = SQL returns values (dump)
x = execute statements (ignore SELECTs)
Where a capital letter is given:
the data is Dumper'd if it's a reference, the result of a sql query, or an object
$pb->debug("duff usage"); # undefined second arg (treated as level 0)
$pb->debug(0, "always tracked"); # debug off
$pb->debug(1, "tracked if $debug =~ /[01]/"); # debug on = decisions
$pb->debug(2, "tracked if $debug =~ /[012]/");# debug on = talkative
$pb-, "tracked if $debug =~ /[oO]/'); # output from methods > data out
A useful combination for the command line may be to set C<$ENV{'Perlbug_Debug'}> 'cs'
Open the file, returns self
$o_file = $o_log->open($file, $perm, $num);
Logs args to log file
$o_log->logg('Done something');
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);
Storage area (file) for results from queries, returns the FH.
my $pos = $log->append('res', 'store this stuff');
# $pos is position in file
Return the results of the queries from this session.
First we look in site, then we look in docs.
my $a_data = $log->read('res');
Truncate this file
my $i_ok = $log->truncate('res');
Set priority nicer by given integer, or by 12.
Sets the given user to the runner of this script.
Copy this to there
$ok = $log->copy($file1, $file2);
@file1_data = $log->copy($file1, $file2);
link this to there
$ok = $log->link($source, $target, [-f]);
Create new file with this data:
$ok = $self->create("$dir/$file.tmp", $data);
Check syntax on given file
$ok = $self->syntax_check("$dir/$file.tmp");
Richard Foley perlbug@rfi.net Oct 1999 2000
| Perlbug documentation | view source | Contained in the Perlbug distribution. |