buildlogs: index.php If there are no errors show last 100 lines (command ex...

arekm arekm at pld-linux.org
Mon Oct 13 00:07:59 CEST 2014


Author: arekm                        Date: Sun Oct 12 22:07:58 2014 GMT
Module: buildlogs                     Tag: HEAD
---- Log message:
If there are no errors show last 100 lines (command execution) or at least from processing files to the end.

---- Files affected:
buildlogs:
   index.php (1.26 -> 1.27) 

---- Diffs:

================================================================
Index: buildlogs/index.php
diff -u buildlogs/index.php:1.26 buildlogs/index.php:1.27
--- buildlogs/index.php:1.26	Sun Oct 12 23:27:06 2014
+++ buildlogs/index.php	Mon Oct 13 00:07:53 2014
@@ -354,8 +354,10 @@
 	$toc = array();
 	$err = array();
 	$err_count = 0;
+	$tail_end = 0;
 	$time = "";
 	$out_buf = array();
+	$out_buf_size = 0;
 	while (($s = fgets($fd, 102400)) != false) {
 		if (strlen($s) > 800) {
 			$s = chunk_split($s, 800, "\n    ");
@@ -392,6 +394,7 @@
 			$s = "<span class=section id={$m['section']}>$s</span>";
 		} elseif (preg_match("/^Processing files: (?P<pkg>(?P<name>.+)-[^-]+-[^-]+)/", $s, $m)) {
 			// processing files
+			$tail_end++;
 			$toc_elem = "files ".$m['name'];
 			$err_elem = $s;
 			$s = "<span class=section id=files-{$m['name']}>$s</span>";
@@ -399,18 +402,23 @@
 			$time = $m['time'];
 		}
 
+		$out_buf[] = $s;
+		$out_buf_size++;
 		// if (not in tail mode) or (in tail mode but we have an error)
-		if ($err_count || !$tail) {
+		if (!$tail || $err_count || $tail_end) {
 			if ($toc_elem)
 				$toc[] = $toc_elem;
 			if ($err_elem)
 				$err[] = $err_elem;
-			$out_buf[] = $s;
+		} else if ($out_buf_size > 100) {
+			// truncate to last 100 elements
+			$out_buf_size -= 100;
+			$out_buf = array_splice($out_buf, 0, $out_buf_size);
 		}
 	}
 	pclose($fd);
 
-	$code = join(' ', $out_buf);
+	$code = join('', $out_buf);
 
 	if ($time) {
 		one_item(_("Runtime"), $time);
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/buildlogs/index.php?r1=1.26&r2=1.27



More information about the pld-cvs-commit mailing list