id => $mfn,
fields => WebPAC::Normalize::_get_marc_fields(),
leader => WebPAC::Normalize::marc_leader(),
+ row => $row,
);
+C<row> is optional parametar which is used when dumping original row to
+error log.
+
=cut
sub add {
if ($self->{lint}) {
$self->{lint}->check_record( $marc );
- my $err = join( "\n", $self->{lint}->warnings );
- $log->error("MARC lint detected warning on record $id\n",
- "<<<<< Original imput row:\n",dump($arg->{row}), "\n",
- ">>>>> Normalized MARC row: leader: [", $marc->leader(), "]\n", dump( $arg->{fields} ), "\n",
- "!!!!! MARC lint warnings:\n",$err,"\n"
- ) if ($err);
+ my @w = $self->{lint}->warnings;
+ if (@w) {
+ $log->error("MARC lint detected warning on record $id\n",
+ "<<<<< Original imput row:\n",dump($arg->{row}), "\n",
+ ">>>>> Normalized MARC row: leader: [", $marc->leader(), "]\n", dump( $arg->{fields} ), "\n",
+ "!!!!! MARC lint warnings:\n",join("\n",@w),"\n"
+ );
+ map { $self->{_marc_lint_warnings}->{$_}++ } @w;
+ }
}
if ($self->{dump}) {
$marc->finish;
+It will also dump MARC lint warnings summary if called with C<lint>.
+
=cut
sub finish {
my $self = shift;
- close( $self->{fh} ) or $self->_get_logger->logdie("can't close ", $self->{path}, ": $!");
+ my $log = $self->get_logger;
+
+ close( $self->{fh} ) or $log->logdie("can't close ", $self->{path}, ": $!");
+
+ if (my $w = $self->{_marc_lint_warnings}) {
+ $log->error("MARC lint warnings summary:\n",
+ join ("\n",
+ map { $w->{$_} . "\t" . $_ }
+ sort { $w->{$b} <=> $w->{$a} } keys %$w
+ )
+ );
+ }
}
=head1 AUTHOR