--- nfo/perl/libs/DesignPattern/Object.pm 2003/02/18 18:34:35 1.7 +++ nfo/perl/libs/DesignPattern/Object.pm 2003/05/13 08:46:08 1.10 @@ -1,7 +1,17 @@ ## --------------------------------------------------------------------------- -## $Id: Object.pm,v 1.7 2003/02/18 18:34:35 joko Exp $ +## $Id: Object.pm,v 1.10 2003/05/13 08:46:08 joko Exp $ ## --------------------------------------------------------------------------- ## $Log: Object.pm,v $ +## Revision 1.10 2003/05/13 08:46:08 joko +## pod and comments +## +## Revision 1.9 2003/03/27 15:44:32 joko +## fixes/enhancements to 'sub log_basic' +## +## Revision 1.8 2003/02/19 00:36:59 joko +## + bugfix: this {logger} is the instance itself, so has to be fed with ( level => xyz and namespace => xyz ) +## + minor modifications in behaviour +## ## Revision 1.7 2003/02/18 18:34:35 joko ## + fix: just logs if possible (sub log_basic) ## @@ -25,6 +35,19 @@ ## ## --------------------------------------------------------------------------- +=pod + +=head1 NAME + + DesignPattern::Object + + +=head1 TODO + + o use Class::Loader + + +=cut package DesignPattern::Object; @@ -161,9 +184,11 @@ eval($evstring); # report errors + # Could this be united with DesignPattern::Loader::checkExceptions? if ($@) { # build error-messages - my $errmsg_native = __PACKAGE__ . ':' . __LINE__ . " Error in eval \"$evstring\": " . $@; + my $issuer = __PACKAGE__ . ':' . __LINE__; + my $errmsg_native = "Error in eval: " . $@; #my $classname = $self->{__classname}; my $errmsg_critical = ''; if ($errmsg_native =~ m/Can't locate (.+?) in \@INC/) { @@ -172,7 +197,7 @@ $errmsg_critical = $errmsg_native; } # write error to logging-output (console|file|database) - $self->log_basic( $errmsg_native, 'debug' ); + $self->log_basic( $errmsg_native . " (issuer='$issuer', code='$evstring')", 'debug' ); $self->log_basic( $errmsg_critical, 'warning' ); return; } @@ -180,6 +205,9 @@ # object-creation my $object = $pkgname->new(@args); + # trace + #print Dumper($object); + # run boot-methods on object $object->_init() if $object->can('_init'); $object->constructor() if $object->can('constructor'); @@ -191,8 +219,19 @@ my $self = shift; my $message = shift; my $level = shift; + + #return; + $level ||= 'info'; + + my $notSoGood = ($level =~ /warning|error|critical/); + + # STDERR? + if ($level && $notSoGood) { + print STDERR $level, ": ", $message, "\n"; + } - if ($_dp_globals->{TRACE} || ($level && $level =~ /warning|error|critical/)) { + # STDOUT? + if ($_dp_globals->{TRACE} || $notSoGood) { print $level, ": ", $message, "\n"; } @@ -202,7 +241,7 @@ } if ($_dp_globals->{logger}) { - $_dp_globals->{logger}->log($level, $message); + $_dp_globals->{logger}->log( level => $level, message => $message); #} else { #print $level, ": ", $message, "\n"; }