r345@llin: dpavlin | 2005-12-31 17:50:23 +0100
[webpac2] / lib / WebPAC / Input.pm
index c2b5fe6..c6ea85e 100644 (file)
@@ -3,11 +3,10 @@ package WebPAC::Input;
 use warnings;
 use strict;
 
-use blib;
-
 use WebPAC::Common;
 use base qw/WebPAC::Common/;
 use Text::Iconv;
+use Data::Dumper;
 
 =head1 NAME
 
@@ -100,7 +99,8 @@ sub new {
        foreach my $subclass (qw/open_db fetch_rec init/) {
                my $n = $self->{module} . '::' . $subclass;
                if (! defined &{ $n }) {
-                       $log->logwarn("missing implementation of $subclass");
+                       my $missing = "missing $subclass in $self->{module}";
+                       $self->{$subclass} = sub { $log->logwarn($missing) };
                } else {
                        $self->{$subclass} = \&{ $n };
                }
@@ -175,7 +175,7 @@ sub open {
        my $code_page = $arg->{'code_page'} || '852';
 
        # store data in object
-       $self->{'code_page'} = $code_page;
+       $self->{'input_code_page'} = $code_page;
        foreach my $v (qw/path offset limit/) {
                $self->{$v} = $arg->{$v} if ($arg->{$v});
        }
@@ -208,7 +208,7 @@ sub open {
        }
 
        if ($self->{limit}) {
-               $log->info("limiting to ",$self->{limit}," records");
+               $log->debug("limiting to ",$self->{limit}," records");
                $limit = $offset + $self->{limit} - 1;
                $limit = $size if ($limit > $size);
        }
@@ -216,7 +216,7 @@ sub open {
        # store size for later
        $self->{size} = ($limit - $offset) ? ($limit - $offset + 1) : 0;
 
-       $log->info("processing $self->{size} records in $code_page, convert to $self->{code_page}");
+       $log->info("processing $self->{size}/$size records [$offset-$limit] convert $code_page -> $self->{code_page}");
 
        # read database
        for (my $pos = $offset; $pos <= $limit; $pos++) {
@@ -225,6 +225,8 @@ sub open {
 
                my $rec = $self->{fetch_rec}->($self, $db, $pos );
 
+               $log->debug(sub { Dumper($rec) });
+
                if (! $rec) {
                        $log->warn("record $pos empty? skipping...");
                        next;