common/tools/brag/logToBRAG.pl
author Simon Howkins <simonh@symbian.org>
Mon, 05 Oct 2009 10:20:32 +0100
changeset 578 75fa4158340a
parent 576 7be9799d1a41
child 579 78b42fd9e2c4
permissions -rw-r--r--
Fixed handling or regular expression strings, so the regular expression functiuonality works, not just substring detection! Added special handling if the severity marker is "ignore". Unsuprisingly, it ignores that line.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
572
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
#
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
#
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Identifies failures in a log file (as determined by a set of rules) and produces a BRAG XML summary
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    19
use Getopt::Long;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    20
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    21
my $phaseName;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
my $stepName;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
my $rulesFile;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
my $help = 0;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
GetOptions((
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
	'phase=s' => \$phaseName,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
	'step=s' => \$stepName,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    28
	'rules=s' => \$rulesFile,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
	'help!' => \$help,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
));
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
my $wrongArgs = 0;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
unless ($help)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    35
	$wrongArgs += warn "No phase specified to indicate the phase that the failures fall under\n" unless defined $phaseName;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
	$wrongArgs += warn "No step specified to indicate the step that the failures fall under\n" unless defined $stepName;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
	$wrongArgs += warn "No file of rules specified to interpret the log file\n" unless defined $rulesFile;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
	$wrongArgs += warn "No log files to process\n" unless @ARGV;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    40
if ($help || $wrongArgs)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    41
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    42
	print <<"EOT";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    43
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    44
logToBRAG.pl --phase=prebuild --step=syncsource --rules=syncsourceRules.tsv presync.log [doSync.log ...] > output.xml
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    45
EOT
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    46
	exit(0 + !$help);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    47
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    48
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    49
# Start to build structure to be output as XML (same format as XML::Parser would create for us)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    50
my $xmlNewline = bless { Text => "\n" }, "Characters";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    51
my $step = bless {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    52
	name => $stepName,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    53
	Kids => [ $xmlNewline ]
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    54
}, "step";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    55
my $phase = bless {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    56
	name => $phaseName,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
	Kids => [ $xmlNewline, $step, $xmlNewline ]
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
}, "phase";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
my $buildStatus = [ bless {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
	Kids =>
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
	[
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
		$xmlNewline,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    63
		$phase,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    64
		$xmlNewline,
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    65
	]
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
}, "buildStatus"];
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    68
# Also create empty <failures> tags with severities in a sensible order
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    69
# And shortcuts to those items
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    70
my $severityShortcut = {};
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    71
foreach my $severity (qw{critical major minor})
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    72
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
	my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
	push @{$step->{Kids}}, $failureSet, $xmlNewline;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
	$severityShortcut->{$severity} = $failureSet;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
# Read rules file
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
my @rules;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    80
open(TSV, $rulesFile) or die "Unable to open rules file '$rulesFile'\n";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    81
while (my $line = <TSV>)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    82
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    83
	chomp $line;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    84
	next unless $line;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
	my @terms = split m{\t+}, $line;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    86
	die "Rules file not formatted as expected at line $.\n" unless scalar @terms == 2;
578
75fa4158340a Fixed handling or regular expression strings, so the regular expression functiuonality works, not just substring detection!
Simon Howkins <simonh@symbian.org>
parents: 576
diff changeset
    87
	push @rules, { regexp => qr{$terms[0]}, severity => $terms[1] };
572
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    88
}	
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    89
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    90
# Iterate through all the lines of all the files in @ARGV
576
7be9799d1a41 Pre-emptive performance fix - avoid having to read the complete log file into memory at the same time before processing it.
Simon Howkins <simonh@symbian.org>
parents: 572
diff changeset
    91
while (my $line = <>)
572
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    92
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    93
	chomp $line;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    94
	foreach my $rule (@rules)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    96
		if ($line =~ m[$rule->{regexp}])
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
		{
578
75fa4158340a Fixed handling or regular expression strings, so the regular expression functiuonality works, not just substring detection!
Simon Howkins <simonh@symbian.org>
parents: 576
diff changeset
    98
			last if $rule->{severity} eq "ignore";
572
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
			# We found a match
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   100
			my $failure = bless{ Kids => [ bless { Text => $line }, "Characters" ] }, "failure";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   101
			# Ensure we have a <failures> tag for this severity
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
			if (!exists $severityShortcut->{$rule->{severity}})
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   103
			{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   104
				# Create the failure set and add it to the shortcut list too
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   105
				my $failureSet = bless { level => $rule->{severity}, Kids => [ $xmlNewline ] }, "failures";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   106
				push @{$step->{Kids}}, $failureSet, $xmlNewline;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   107
				$severityShortcut->{$rule->{severity}} = $failureSet;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
			}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
			push @{$severityShortcut->{$rule->{severity}}->{Kids}}, $failure, $xmlNewline;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
			# Do not consider any more rules
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
			last;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   113
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   114
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   115
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116
# Print XML
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   117
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   118
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   119
printTree($buildStatus->[0]);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
print "\n";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   121
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   122
exit(0);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
sub printTree
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   126
	my $tree = shift or die;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
	die unless ref $tree;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
	my $tagName = ref $tree;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
	$tagName =~ s{^main::}{};
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
	if ($tagName eq "Characters")
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
		print $tree->{Text};
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
		return;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   136
	
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
	print "<$tagName";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
	foreach my $attr (
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
		sort {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   141
			my $order = "name level start stop href";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   142
			my $ixA = index $order, $a;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   143
			my $ixB = index $order, $b;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   144
			die "$a $b" if $ixA + $ixB == -2;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   145
			$ixA - $ixB;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   146
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   147
		grep {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   148
			! ref $tree->{$_}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   149
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   150
		keys %$tree)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   151
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   152
		print " $attr=\"$tree->{$attr}\"";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   154
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
	my $children = $tree->{Kids} || [];
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   156
	if (scalar @$children)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   157
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
		print ">";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
		foreach my $child (@$children)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
		{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
			printTree($child);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
		print "</$tagName";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   165
	else
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
		print "/"
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
	print ">";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   172