From 2b62f835a1e79fcc74e2ac25da089aa2c2e4f784 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 4 Jul 2006 11:36:21 +0000 Subject: [PATCH] r802@llin: dpavlin | 2006-07-04 13:36:05 +0200 added MARC lint warning summary git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@582 07558da8-63fa-0310-ba24-9fe276d99e06 --- lib/WebPAC/Output/MARC.pm | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/WebPAC/Output/MARC.pm b/lib/WebPAC/Output/MARC.pm index 7d0ea31..8c43371 100644 --- a/lib/WebPAC/Output/MARC.pm +++ b/lib/WebPAC/Output/MARC.pm @@ -72,8 +72,12 @@ sub new { id => $mfn, fields => WebPAC::Normalize::_get_marc_fields(), leader => WebPAC::Normalize::marc_leader(), + row => $row, ); +C is optional parametar which is used when dumping original row to +error log. + =cut sub add { @@ -110,12 +114,15 @@ 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}) { @@ -135,12 +142,25 @@ Close MARC output file $marc->finish; +It will also dump MARC lint warnings summary if called with C. + =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 -- 2.20.1