--- trunk/run.pl 2006/09/11 11:57:18 664 +++ trunk/run.pl 2006/09/11 15:59:35 671 @@ -363,6 +363,16 @@ %{ $input }, ); + my $report_fh; + if ($stats || $validate) { + my $path = "out/report/" . $database . '-' . $input->{name} . '.txt'; + open($report_fh, '>', $path) || $log->logdie("can't open $path: $!"); + + print $report_fh "Report for database '$database' input '$input->{name}' records ", + $offset || 1, "-", $limit || $input->{limit} || $maxmfn, "\n\n"; + $log->info("Generating report file $path"); + } + my @norm_array = ref($input->{normalize}) eq 'ARRAY' ? @{ $input->{normalize} } : ( $input->{normalize} ); @@ -408,7 +418,7 @@ if ($validate) { if ( my $errors = $validate->validate_errors( $row, $input_db->dump ) ) { $log->error( "MFN $mfn validation error:\n", - dump( $errors ) + $validate->report_error( $errors ) ); } } @@ -465,14 +475,23 @@ if ($validate) { my $errors = $validate->report; - $log->info("validation errors:\n$errors\n" ) if ($errors); + if ($errors) { + $log->info("validation errors:\n$errors\n" ); + print $report_fh "$errors\n" if ($report_fh); + } } - $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats); + if ($stats) { + my $s = $input_db->stats; + $log->info("statistics of fields usage:\n$s"); + print $report_fh "Statistics of fields usage:\n$s" if ($report_fh); + } # close MARC file $marc->finish if ($marc); + # close report + close($report_fh) || $log->logdie("can't close report: $!"); } }