--- nfo/perl/libs/Data/Storage.pm 2003/02/18 19:22:11 1.19 +++ nfo/perl/libs/Data/Storage.pm 2003/06/25 22:51:51 1.20 @@ -1,6 +1,6 @@ ## ------------------------------------------------------------------------ ## -## $Id: Storage.pm,v 1.19 2003/02/18 19:22:11 joko Exp $ +## $Id: Storage.pm,v 1.20 2003/06/25 22:51:51 joko Exp $ ## ## Copyright (c) 2002 Andreas Motl ## @@ -9,6 +9,9 @@ ## ------------------------------------------------------------------------ ## ## $Log: Storage.pm,v $ +## Revision 1.20 2003/06/25 22:51:51 joko +## + sub get_locator_type & Co. +## ## Revision 1.19 2003/02/18 19:22:11 joko ## + fixed logging ## @@ -149,10 +152,16 @@ my $method = $AUTOLOAD; $method =~ s/^.*:://; + #print __PACKAGE__, "\n"; + #print $method, "\n"; + #print $self->{locator}, "\n"; + + my $locator_type = $self->get_locator_type(); + # advanced logging of AUTOLOAD calls ... # ... nice but do it only when TRACING (TODO) is enabled my $logstring = ""; - $logstring .= __PACKAGE__ . "[$self->{locator}->{type}]" . "->" . $method; + $logstring .= __PACKAGE__ . "[$locator_type]" . "->" . $method; #print "count: ", $#_, "\n"; #$logstring .= Dumper(@_) if ($#_ != -1); my $tabcount = int( (80 - length($logstring)) / 10 ); @@ -172,7 +181,9 @@ if ($self->{STORAGEHANDLE}) { return $self->{STORAGEHANDLE}->$method(@_); } else { - $logger->critical( __PACKAGE__ . "->AUTOLOAD: ERROR: " . $logstring ); + my $msg = __PACKAGE__ . "->AUTOLOAD: ERROR: " . $logstring; + $logger->critical( $msg ) if $logger; + print STDERR $msg if not $logger; return; } } @@ -231,7 +242,11 @@ sub _createStorageHandle { my $self = shift; - my $type = $self->{locator}->{type}; + + # 2003-06-18: protection against storagehandles w/o locators + return if not defined $self->{locator}; + + my $type = $self->get_locator_type(); $logger->debug( __PACKAGE__ . "[$type]" . "->_createStorageHandle()" ); #print Dumper($self); @@ -298,6 +313,12 @@ $logger->remove($name); } +sub get_locator_type { + my $self = shift; + my $locator_type = ''; + $locator_type = $self->{locator}->{type} if defined $self->{locator}; + return $locator_type; +} 1; __END__