# HG changeset patch # User Dario Sestito # Date 1247503925 -3600 # Node ID 9544c55a7fd00dc7a49788e627ba89241cd80d80 # Parent 51e429810aba4d757d0b7a077ff3d217f9b789d9 Raptor parser to provide summary csv file so that faults can be readily put into db diff -r 51e429810aba -r 9544c55a7fd0 common/tools/raptor/RaptorCommon.pm --- a/common/tools/raptor/RaptorCommon.pm Mon Jul 13 11:38:30 2009 +0100 +++ b/common/tools/raptor/RaptorCommon.pm Mon Jul 13 17:52:05 2009 +0100 @@ -15,9 +15,21 @@ package RaptorCommon; our $CATEGORY_GENERAL = 'general'; + our $CATEGORY_RAPTORERROR = 'raptor_error'; +our $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version'; +our $CATEGORY_RAPTORERROR_NOBLDINFFOUND = 'no_bld_inf_found'; our $SEVERITY_UNKNOWN = 'unknown'; our $SEVERITY_CRITICAL = 'critical'; +sub dump_fault +{ + my ($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line) = @_; + + open(SUMMARY, ">>$::basedir/summary.csv"); + print SUMMARY "$category,$subcategory,$severity,$component,$phase,$recipe,$file,$line\n"; + close(SUMMARY); +} + 1; diff -r 51e429810aba -r 9544c55a7fd0 common/tools/raptor/RaptorError.pm --- a/common/tools/raptor/RaptorError.pm Mon Jul 13 11:38:30 2009 +0100 +++ b/common/tools/raptor/RaptorError.pm Mon Jul 13 17:52:05 2009 +0100 @@ -34,28 +34,41 @@ $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error'; $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error'; +my $filename = ''; + my $characters = ''; my $category = $RaptorCommon::CATEGORY_RAPTORERROR; sub process { - my ($text) = @_; + my ($text, $component, $phase, $recipe, $file, $line) = @_; my $severity = $RaptorCommon::SEVERITY_UNKNOWN; if ($text =~ m,Cannot process schema version .* of file,) { $severity = $RaptorCommon::SEVERITY_CRITICAL; - - #dump_error($category, $severity, $text); - print "$category, $severity, $text\n"; + my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION; + RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line); + } + elsif ($text =~ m,No bld\.inf found at,) + { + $severity = $RaptorCommon::SEVERITY_CRITICAL; + my $subcategory = $RaptorCommon::CATEGORY_RAPTORERROR_NOBLDINFFOUND; + RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line); + } + else # log everything by default + { + $severity = $RaptorCommon::SEVERITY_UNKNOWN; + my $subcategory = ''; + RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line); } } sub on_start_buildlog_error { - my $filename = "$::basedir/errors.txt"; + $filename = "$::basedir/errors.txt"; print "Writing error file $filename\n" if (!-f$filename); open(FILE, ">>$filename"); } @@ -75,14 +88,19 @@ { #print "on_end_buildlog_error\n"; - process($characters); - print FILE $characters if ($characters =~ m,[^\s^\r^\n],); print FILE "\n" if ($characters !~ m,[\r\n]$, ); + close(FILE); + + # get the line number - not really optimized + my $linecount = 0; + open(FILE, "$filename"); + for ($linecount = 0; ; $linecount++) { } + close(FILE); + + process($characters, '', '', '', "errors.txt", $linecount); $characters = ''; - - close(FILE); }