uh_parser/RaptorError.pm
changeset 209 ba90e30c0f3c
parent 185 b76adfbc6648
child 211 c01247054e72
--- a/uh_parser/RaptorError.pm	Wed Apr 07 16:07:31 2010 +0100
+++ b/uh_parser/RaptorError.pm	Wed Apr 07 17:31:01 2010 +0100
@@ -37,6 +37,8 @@
 
 my $filename = '';
 
+my $raptor_error_info = {};
+
 my $characters = '';
 
 my $CATEGORY_RAPTORERROR = 'raptor_error';
@@ -135,18 +137,22 @@
 sub on_start_buildlog
 {
 	RaptorCommon::init();
-	
-	$filename = "$::raptorbitsdir/raptor_error.txt";
-	if (!-f$filename)
-	{
-		print "Writing errors file $filename\n";
-		open(FILE, ">$filename");
-		close(FILE);
-	}
 }
 
 sub on_start_buildlog_error
 {
+  my ($el) = @_;
+	
+	#print "on_start_buildlog_error\n";
+	
+	$raptor_error_info = {};
+	
+	my $attributes = $el->{Attributes};
+	for (keys %{$attributes})
+	{
+		$raptor_error_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'};
+		#print "$_ -> $attributes->{$_}->{'Value'}\n";
+	}
 }
 
 sub on_chars_buildlog_error
@@ -164,12 +170,51 @@
 {
 	#print "on_end_buildlog_error\n";
 	
+	my $package = '';
+	if ($raptor_error_info->{bldinf})
+	{
+    $::allbldinfs->{$raptor_error_info->{bldinf}} = 1;
+    
+    # normalize bldinf path
+		$raptor_error_info->{bldinf} = lc($raptor_error_info->{bldinf});
+		$raptor_error_info->{bldinf} =~ s,^[A-Za-z]:,,;
+		$raptor_error_info->{bldinf} =~ s,[\\],/,g;
+		
+		if ($raptor_error_info->{bldinf} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),)
+		{
+			$package = $1;
+			$package =~ s,/,_,;
+		}
+		else
+		{
+			print "WARNING: can't understand bldinf attribute of raptor error: $raptor_error_info->{bldinf}. Won't associate to package.\n";
+		}
+  }
+	
 	$characters =~ s,^[\r\n]*,,;
 	$characters =~ s,[\r\n]*$,,;
 	
 	if ($characters =~ m,[^\s^\r^\n],)
-	{	
-		my $dumped = process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt");
+	{
+    my $bldinf_field = '';
+    if ($package)
+		{
+			$filename = "$::raptorbitsdir/$package.txt";
+			$bldinf_field = $raptor_error_info->{bldinf};
+		}
+		else
+		{
+		  $filename = "$::raptorbitsdir/raptor_error.txt";
+		}
+		
+		if (!-f$filename)
+		{
+			print "Writing file $filename\n";
+			open(FILE, ">$filename");
+			close(FILE);
+		}
+		
+		my $dumped = process($characters, $::current_log_file, $bldinf_field, '', '', '', "$package.txt");
 		
 		if ($dumped)
 		{