Perlbug::Log - Module for generic logging/debugging functions to all Perlbug.


Perlbug documentation  | view source Contained in the Perlbug distribution.

Index


NAME

Top

Perlbug::Log - Module for generic logging/debugging functions to all Perlbug.

DESCRIPTION

Top

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

SYNOPSIS

Top

	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

Top

new

Create new Perlbug::Log object

    my $obj = Perlbug::Log->new('log' => $log, 'tmp => $tmp, 'debug' => 2);

files

Return files based on key (or all)

	my @files = $o_log->files();

handle

Return handle based on key

	my $fh = $o_log->handle('log');

DESTROY

Cleanup log and tmp files.

debug

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

Open the file, returns self

	$o_file = $o_log->open($file, $perm, $num);

logg

Logs args to log file

	$o_log->logg('Done something');

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.

First we look in site, then we look in docs.

    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 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");

AUTHOR

Top

Richard Foley perlbug@rfi.net Oct 1999 2000


Perlbug documentation  | view source Contained in the Perlbug distribution.