Cache the brief log html. Make it fast.

This commit is contained in:
slamm%netscape.com 1999-03-19 20:37:07 +00:00
Родитель 69a335d6da
Коммит ddd87047ea
1 изменённых файлов: 133 добавлений и 124 удалений

Просмотреть файл

@ -17,175 +17,178 @@
# Corporation. Portions created by Netscape are Copyright (C) 1998 # Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved. # Netscape Communications Corporation. All Rights Reserved.
use lib "../bonsai"; use lib '../bonsai';
require 'globals.pl'; require 'globals.pl';
require 'lloydcgi.pl'; require 'lloydcgi.pl';
require 'header.pl'; require 'header.pl';
#############################################################
$|=1; # Global variables
$LINES_AFTER_ERROR = 5; $LINES_AFTER_ERROR = 5;
$LINES_BEFORE_ERROR = 30; $LINES_BEFORE_ERROR = 30;
# These variables are set by the error parser functions:
# has_error(), has_warning(), and has_errorline().
$error_file = ''; $error_file = '';
$error_file_ref = ''; $error_file_ref = '';
$error_line = 0; $error_line = 0;
$error_guess = 0; $error_guess = 0;
print "Content-type: text/html\n\n";
$error_count = 0;
$next_err = 0; $next_err = 0;
@log_errors = (); @log_errors = ();
$log_ln = 0; $log_line = 0;
if (1) { #############################################################
$tree = $form{'tree'}; # CGI inputs
$errorparser = $form{'errorparser'};
$logfile = $form{'logfile'}; $tree = $form{tree};
$summary = $form{'summary'}; $errorparser = $form{errorparser};
$buildname = $form{'buildname'}; $logfile = $form{logfile};
$buildtime = $form{'buildtime'}; $buildname = $form{buildname};
$enc_buildname = &url_encode($buildname); $buildtime = $form{buildtime};
$frames = $form{'frames'}; $enc_buildname = &url_encode($buildname);
$fulltext = $form{'fulltext'}; $fulltext = $form{fulltext};
$mainframe = $form{'mainframe'};
#print "$buildname \n $buildtime \n $errorparser \n $logfile \n $tree \n $enc_buildname \n";
}
else {
$tree = 'FreeSource';
$errorparser = 'windows';
$logfile = '19692.gz';
}
die "the \"tree\" parameter must be provided\n" unless $tree; die "the \"tree\" parameter must be provided\n" unless $tree;
require "$tree/treedata.pl"; require "$tree/treedata.pl";
if( $mainframe ){
print "
<HTML>
<FRAMESET name = main ROWS='70%, 30%'>
<FRAME NAME='log' SCROLL=AUTO SRC='showlog.cgi?tree=$tree&errorparser=$errorparser&logfile=$logfile&summary=$summary&buildtime=$buildtime&buildname=$enc_buildname&fulltext=$fulltext&frames=1'>
<FRAME NAME='SOURCEFRAME' SCROLL='AUTO' SRC='Empty.html'>
</FRAMESET>
</HTML>
";
exit 0;
}
if( $frames ){
$source_target = "target=SOURCEFRAME";
}
#
# Dynamically load the error parser # Dynamically load the error parser
# #
die "the \"errorparser\" parameter must be provided\n" unless $errorparser; die "the \"errorparser\" parameter must be provided\n" unless $errorparser;
require "ep_${errorparser}.pl"; require "ep_${errorparser}.pl";
$time_str = print_time( $form{'buildtime'} );
if( $fulltext ){ $time_str = print_time( $buildtime );
$|=1;
&print_header;
&print_notes;
if ($fulltext)
{
&print_summary;
&print_log;
}
else
{
$brief_filename = $logfile;
$brief_filename =~ s/.gz$/.brief.html/;
if (-T "$tree/$brief_filename")
{
open (BRIEFFILE, "<$tree/$brief_filename");
print while (<BRIEFFILE>)
}
else
{
open (BRIEFFILE, ">$tree/$brief_filename");
&print_summary;
&print_log;
}
}
# end of main
############################################################
sub print_header {
print "Content-type: text/html\n\n";
if( $fulltext ){
$s = 'Show <b>Brief</b> Log'; $s = 'Show <b>Brief</b> Log';
$s1 = ''; $s1 = '';
$s2 = 'Full'; $s2 = 'Full';
} }
else { else {
$s = 'Show <b>Full</b> Log'; $s = 'Show <b>Full</b> Log';
$s1 = 1; $s1 = 1;
$s2 = 'Brief'; $s2 = 'Brief';
} }
print "<META HTTP-EQUIV=\"EXPIRES\" CONTENT=\"1\">\n"; print "<META HTTP-EQUIV=\"EXPIRES\" CONTENT=\"1\">\n";
my $heading = "Build Log ($s2)"; my $heading = "Build Log ($s2)";
my $subheading = "$form{'buildname'} on $time_str"; my $subheading = "$buildname on $time_str";
my $title = "$heading - $subheading"; my $title = "$heading - $subheading";
EmitHtmlTitleAndHeader($title, $heading, $subheading); EmitHtmlTitleAndHeader($title, $heading, $subheading);
print " print "
<font size=+1> <font size=+1>
<dt><a href='showlog.cgi?tree=$tree&errorparser=$errorparser&logfile=$logfile&summary=$summary&buildtime=$buildtime&buildname=$enc_buildname&fulltext=$s1&frames=1'>$s</a> <dt><a href='showlog.cgi?tree=$tree&errorparser=$errorparser&logfile=$logfile&buildtime=$buildtime&buildname=$enc_buildname&fulltext=$s1'>$s</a>
<dt><a href=\"showbuilds.cgi?tree=$form{'tree'}\">Return to the Build Page</a> <dt><a href=\"showbuilds.cgi?tree=$tree\">Return to the Build Page</a>
<dt><a href=\"addnote.cgi?tree=$tree\&buildname=$enc_buildname\&buildtime=$buildtime\&logfile=$logfile\&errorparser=$errorparser\"> <dt><a href=\"addnote.cgi?tree=$tree\&buildname=$enc_buildname\&buildtime=$buildtime\&logfile=$logfile\&errorparser=$errorparser\">
Add a Comment to the Log</a> Add a Comment to the Log</a>
</font> </font>
"; ";
}
# sub print_notes {
# Print notes #
# # Print notes
$found_note = 0; #
open(NOTES,"<$tree/notes.txt") || print "<h2>warning: Couldn't open $tree/notes.txt </h2>\n"; $found_note = 0;
while(<NOTES>){ open(NOTES,"<$tree/notes.txt")
or print "<h2>warning: Couldn't open $tree/notes.txt </h2>\n";
while(<NOTES>){
chop; chop;
($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/); ($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/);
#print "$_<br>\n"; #print "$_<br>\n";
if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){ if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){
if( !$found_note ){ if( !$found_note ){
print "<H2>Build Comments</H2>\n"; print "<H2>Build Comments</H2>\n";
$found_note = 1; $found_note = 1;
} }
$now_str = &print_time($nnow); $now_str = &print_time($nnow);
$note = &url_decode($nenc_note); $note = &url_decode($nenc_note);
print "<pre>\n[<b><a href=mailto:$nwho>$nwho</a> - $now_str</b>]\n$note\n</pre>"; print "<pre>\n[<b><a href=mailto:$nwho>$nwho</a> - $now_str</b>]\n$note\n</pre>";
} }
}
close(NOTES);
} }
close(NOTES);
# sub print_summary {
# Print the summery fisrt #
# # Print the summary first
print " #
<H2>Build Error Summary</H2> logprint('<H2>Build Error Summary</H2><PRE>');
<p> Click error to take you to the error in the log.
<PRE> $log_line = 0;
"; open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
$log_ln = 0; while( $line = <BUILD_IN> ){
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
while( $line = <BUILD_IN> ){
&output_summary_line( $line ); &output_summary_line( $line );
}
close( BUILD_IN );
push @log_errors, 9999999;
logprint('</PRE>');
} }
close( BUILD_IN );
push @log_errors, 9999999;
print "</PRE>\n"; sub print_log {
#
# reset the error counter
#
$next_err = 0;
# logprint('<H2>Build Error Log</H2><pre>');
# reset the error counter
#
$next_err = 0;
$log_line = 0;
print "<H2>Build Error Log</H2>\n<pre>"; open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
$log_ln = 0; while( $line = <BUILD_IN> ){
open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
while( $line = <BUILD_IN> ){
&output_log_line( $line ); &output_log_line( $line );
}
close( BUILD_IN );
logprint('</PRE><p>'
."<font size=+1><a name=\"err$next_err\">No More Errors</a></font>"
.'<br><br><br>');
} }
close( BUILD_IN );
print
"</PRE>
<p>
<font size=+1><a name=\"err$next_err\">No More Errors</a></font>
<br>
<br>
<br>
";
sub output_summary_line { sub output_summary_line {
local( $line ) = @_; my( $line ) = $_[0];
local( $has_error ); my( $has_error );
$has_error = &has_error( $line ); $has_error = &has_error( $line );
@ -193,9 +196,9 @@ sub output_summary_line {
$line =~ s/</&lt;/g; $line =~ s/</&lt;/g;
if( $has_error ){ if( $has_error ){
push @log_errors, $log_ln + $LINES_AFTER_ERROR; push @log_errors, $log_line + $LINES_AFTER_ERROR;
if( ! $last_was_error ) { if( ! $last_was_error ) {
print "<a href=\"#err$next_err\">$line</a>"; logprint("<a href=\"#err$next_err\">$line</a>");
$next_err++; $next_err++;
} }
$last_was_error = 1; $last_was_error = 1;
@ -204,14 +207,14 @@ sub output_summary_line {
$last_was_error = 0; $last_was_error = 0;
} }
$log_ln++; $log_line++;
} }
sub output_log_line { sub output_log_line {
local( $line, $bSummary ) = @_; my( $line ) = $_[0];
local( $has_error, $dur, $dur_min,$dur_sec, $dur_str, $logline ); my( $has_error, $dur, $dur_min,$dur_sec, $dur_str, $logline );
$has_error = &has_error( $line ); $has_error = &has_error( $line );
$has_warning = &has_warning( $line ); $has_warning = &has_warning( $line );
@ -258,25 +261,31 @@ sub output_log_line {
sub push_log_line { sub push_log_line {
local( $ln ) = @_; my( $line ) = $_[0];
if( $fulltext ){ if( $fulltext ){
print $ln; logprint($line);
return; return;
} }
if( $log_ln > $log_errors[$cur_error] ){ if( $log_line > $log_errors[$cur_error] ){
$cur_error++; $cur_error++;
} }
if( $log_ln >= $log_errors[$cur_error] - $LINES_BEFORE_ERROR ){ if( $log_line >= $log_errors[$cur_error] - $LINES_BEFORE_ERROR ){
if( $log_skip != 0 ){ if( $log_skip != 0 ){
print "\n<i><font size=+1> Skipping $log_skip Lines...</i></font>\n\n"; logprint("\n<i><font size=+1> Skipping $log_skip Lines...</i></font>\n\n");
$log_skip = 0; $log_skip = 0;
} }
print $ln; logprint($line);
} }
else { else {
$log_skip++; $log_skip++;
} }
$log_ln++; $log_line++;
}
sub logprint {
my $line = $_[0];
print $line;
print BRIEFFILE $line if not $fulltext;
} }