From ddd87047eab323c594b06fa578fbad354daa5682 Mon Sep 17 00:00:00 2001 From: "slamm%netscape.com" Date: Fri, 19 Mar 1999 20:37:07 +0000 Subject: [PATCH] Cache the brief log html. Make it fast. --- webtools/tinderbox/showlog.cgi | 257 +++++++++++++++++---------------- 1 file changed, 133 insertions(+), 124 deletions(-) diff --git a/webtools/tinderbox/showlog.cgi b/webtools/tinderbox/showlog.cgi index 84e1fce23b2f..9f5cac655d38 100755 --- a/webtools/tinderbox/showlog.cgi +++ b/webtools/tinderbox/showlog.cgi @@ -17,175 +17,178 @@ # Corporation. Portions created by Netscape are Copyright (C) 1998 # Netscape Communications Corporation. All Rights Reserved. -use lib "../bonsai"; +use lib '../bonsai'; require 'globals.pl'; require 'lloydcgi.pl'; require 'header.pl'; - -$|=1; +############################################################# +# Global variables $LINES_AFTER_ERROR = 5; $LINES_BEFORE_ERROR = 30; +# These variables are set by the error parser functions: +# has_error(), has_warning(), and has_errorline(). $error_file = ''; $error_file_ref = ''; $error_line = 0; $error_guess = 0; -print "Content-type: text/html\n\n"; - -$error_count = 0; - $next_err = 0; - @log_errors = (); -$log_ln = 0; +$log_line = 0; -if (1) { - $tree = $form{'tree'}; - $errorparser = $form{'errorparser'}; - $logfile = $form{'logfile'}; - $summary = $form{'summary'}; - $buildname = $form{'buildname'}; - $buildtime = $form{'buildtime'}; - $enc_buildname = &url_encode($buildname); - $frames = $form{'frames'}; - $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'; -} +############################################################# +# CGI inputs + +$tree = $form{tree}; +$errorparser = $form{errorparser}; +$logfile = $form{logfile}; +$buildname = $form{buildname}; +$buildtime = $form{buildtime}; +$enc_buildname = &url_encode($buildname); +$fulltext = $form{fulltext}; die "the \"tree\" parameter must be provided\n" unless $tree; require "$tree/treedata.pl"; -if( $mainframe ){ - print " - - - - - - -"; - exit 0; -} - -if( $frames ){ - $source_target = "target=SOURCEFRAME"; -} - - -# # Dynamically load the error parser # die "the \"errorparser\" parameter must be provided\n" unless $errorparser; 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 () + } + 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 Brief Log'; $s1 = ''; $s2 = 'Full'; -} -else { + } + else { $s = 'Show Full Log'; $s1 = 1; $s2 = 'Brief'; -} + } + + print "\n"; -print "\n"; + my $heading = "Build Log ($s2)"; + my $subheading = "$buildname on $time_str"; + my $title = "$heading - $subheading"; -my $heading = "Build Log ($s2)"; -my $subheading = "$form{'buildname'} on $time_str"; -my $title = "$heading - $subheading"; + EmitHtmlTitleAndHeader($title, $heading, $subheading); -EmitHtmlTitleAndHeader($title, $heading, $subheading); - -print " + print " -
$s -
Return to the Build Page +
$s +
Return to the Build Page
Add a Comment to the Log "; +} -# -# Print notes -# -$found_note = 0; -open(NOTES,"<$tree/notes.txt") || print "

warning: Couldn't open $tree/notes.txt

\n"; -while(){ +sub print_notes { + # + # Print notes + # + $found_note = 0; + open(NOTES,"<$tree/notes.txt") + or print "

warning: Couldn't open $tree/notes.txt

\n"; + while(){ chop; ($nbuildtime,$nbuildname,$nwho,$nnow,$nenc_note) = split(/\|/); #print "$_
\n"; if( $nbuildtime == $buildtime && $nbuildname eq $buildname ){ - if( !$found_note ){ - print "

Build Comments

\n"; - $found_note = 1; - } - $now_str = &print_time($nnow); - $note = &url_decode($nenc_note); - print "
\n[$nwho - $now_str]\n$note\n
"; + if( !$found_note ){ + print "

Build Comments

\n"; + $found_note = 1; + } + $now_str = &print_time($nnow); + $note = &url_decode($nenc_note); + print "
\n[$nwho - $now_str]\n$note\n
"; } + } + close(NOTES); } -close(NOTES); -# -# Print the summery fisrt -# -print " -

Build Error Summary

-

Click error to take you to the error in the log. -

-";
-$log_ln = 0;
-open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
-while( $line =  ){
+sub print_summary {
+  #
+  # Print the summary first
+  #
+  logprint('

Build Error Summary

');
+
+  $log_line = 0;
+  open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
+  while( $line =  ){
     &output_summary_line( $line );
+  }
+  close( BUILD_IN );
+  push @log_errors, 9999999;        
+
+  logprint('
'); } -close( BUILD_IN ); -push @log_errors, 9999999; -print "
\n"; +sub print_log { + # + # reset the error counter + # + $next_err = 0; + + logprint('

Build Error Log

');
 
-#
-# reset the error counter
-#
-$next_err = 0;
-
- 
-print "

Build Error Log

\n
";
-$log_ln = 0;
-open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
-while( $line =  ){
+  $log_line = 0;
+  open( BUILD_IN, "$gzip -d -c $tree/$logfile|" );
+  while( $line =  ){
     &output_log_line( $line );
+  }
+  close( BUILD_IN );
+
+  logprint('

' + ."No More Errors" + .'


'); } -close( BUILD_IN ); - - -print -"

- -

-No More Errors -
-
-
-"; - sub output_summary_line { - local( $line ) = @_; - local( $has_error ); + my( $line ) = $_[0]; + my( $has_error ); $has_error = &has_error( $line ); @@ -193,9 +196,9 @@ sub output_summary_line { $line =~ s/$line"; + logprint("$line"); $next_err++; } $last_was_error = 1; @@ -204,14 +207,14 @@ sub output_summary_line { $last_was_error = 0; } - $log_ln++; + $log_line++; } sub output_log_line { - local( $line, $bSummary ) = @_; - local( $has_error, $dur, $dur_min,$dur_sec, $dur_str, $logline ); + my( $line ) = $_[0]; + my( $has_error, $dur, $dur_min,$dur_sec, $dur_str, $logline ); $has_error = &has_error( $line ); $has_warning = &has_warning( $line ); @@ -258,25 +261,31 @@ sub output_log_line { sub push_log_line { - local( $ln ) = @_; + my( $line ) = $_[0]; if( $fulltext ){ - print $ln; + logprint($line); return; } - if( $log_ln > $log_errors[$cur_error] ){ + if( $log_line > $log_errors[$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 ){ - print "\n Skipping $log_skip Lines...\n\n"; + logprint("\n Skipping $log_skip Lines...\n\n"); $log_skip = 0; } - print $ln; + logprint($line); } else { $log_skip++; } - $log_ln++; + $log_line++; +} + +sub logprint { + my $line = $_[0]; + print $line; + print BRIEFFILE $line if not $fulltext; }