common/tools/brag/logToBRAG.pl
author Simon Howkins <simonh@symbian.org>
Fri, 02 Oct 2009 16:19:09 +0100
changeset 576 7be9799d1a41
parent 572 974b8ee5b70e
child 578 75fa4158340a
permissions -rw-r--r--
Pre-emptive performance fix - avoid having to read the complete log file into memory at the same time before processing it.
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;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
	push @rules, { regexp => $terms[0], severity => $terms[1] };
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
		{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    98
			# We found a match
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
			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
   100
			# 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
   101
			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
   102
			{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   103
				# 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
   104
				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
   105
				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
   106
				$severityShortcut->{$rule->{severity}} = $failureSet;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   107
			}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
			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
   109
			# 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
   110
			last;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
		}
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
# Print XML
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   116
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
   117
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
   118
printTree($buildStatus->[0]);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   119
print "\n";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   121
exit(0);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   122
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
sub printTree
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
	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
   126
	die unless ref $tree;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
	my $tagName = ref $tree;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
	$tagName =~ s{^main::}{};
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
	if ($tagName eq "Characters")
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
		print $tree->{Text};
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
		return;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
	}
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
	print "<$tagName";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
	foreach my $attr (
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
		sort {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
			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
   141
			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
   142
			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
   143
			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
   144
			$ixA - $ixB;
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   145
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   146
		grep {
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   147
			! ref $tree->{$_}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   148
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   149
		keys %$tree)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   150
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   151
		print " $attr=\"$tree->{$attr}\"";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   152
	}
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
	my $children = $tree->{Kids} || [];
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
	if (scalar @$children)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   156
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   157
		print ">";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
		foreach my $child (@$children)
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
		{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
			printTree($child);
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
		}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
		print "</$tagName";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
	}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
	else
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   165
	{
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
		print "/"
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
	}
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
	print ">";
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
}
974b8ee5b70e Added framework script for turning log files into XML BRAG summaries.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171