common/tools/raptor/RaptorWarning.pm
changeset 374 52675b624b66
parent 364 4dc3b5b1577c
--- a/common/tools/raptor/RaptorWarning.pm	Mon Aug 24 15:09:22 2009 +0100
+++ b/common/tools/raptor/RaptorWarning.pm	Wed Aug 26 12:30:59 2009 +0100
@@ -36,27 +36,29 @@
 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
 
 my $filename = '';
+my $failure_item = 0;
 
 my $characters = '';
 
-my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
+my $CATEGORY_RAPTORWARNING = 'raptor_warning';
+my $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2 = 'missing_enable_abiv2_mode';
 
 sub process
 {
 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
 	
-	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
+	my $category = $CATEGORY_RAPTORWARNING;
+	my $severity = '';
+	my $subcategory = '';
 	
 	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
 	{
-		$severity = $RaptorCommon::SEVERITY_NORMAL;
-		my $subcategory = $RaptorCommon::CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
+		$severity = $RaptorCommon::SEVERITY_MINOR;
+		my $subcategory = $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
 	}
 	else # log everything by default
 	{
-		$severity = $RaptorCommon::SEVERITY_NORMAL;
-		my $subcategory = '';
 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
 	}
 }
@@ -65,7 +67,7 @@
 {
 	RaptorCommon::init();
 	
-	$filename = "$::basedir/warnings.txt";
+	$filename = "$::basedir/raptor_warning.txt";
 	if (!-f$filename)
 	{
 		print "Writing warnings file $filename\n";
@@ -93,17 +95,31 @@
 {
 	#print "on_end_buildlog_warning\n";
 	
-	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
-	print FILE "\n" if ($characters !~ m,[\r\n]$, );
-	close(FILE);
+	$characters =~ s,^[\r\n]*,,;
+	$characters =~ s,[\r\n]*$,,;
 	
-	# get the line number - not really optimized
-	my $linecount = 0;
-	open(FILE, "$filename");
-	for ($linecount = 0; <FILE>; $linecount++) { }
-	close(FILE);
+	if ($characters =~ m,[^\s^\r^\n],)
+	{
+		if ($failure_item == 0 and -f "$filename")
+		{
+			open(FILE, "$filename");
+			{
+				local $/ = undef;
+				my $filecontent = <FILE>;
+				$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
+			}
+			close(FILE);
+		}
+		
+		$failure_item++;
 	
-	process($characters, '', '', '', "warnings.txt", $linecount);
+		open(FILE, ">>$filename");
+		print FILE "---failure_item_$failure_item\---\n";
+		print FILE "$characters\n\n";
+		close(FILE);
+		
+		process($characters, '', '', '', "raptor_warning.txt", $failure_item);
+	}
 	
 	$characters = '';
 }