Don't mix data model and UI: move debug javascript to js module, also use jquery because raw javascript without validation is dangerous
[gitphp.git] / include / DebugLog.class.php
blob:a/include/DebugLog.class.php -> blob:b/include/DebugLog.class.php
--- a/include/DebugLog.class.php
+++ b/include/DebugLog.class.php
@@ -208,6 +208,16 @@
 	}
 
 	/**
+	 * Gets the log entries
+	 *
+	 * @return array entry data
+	 */
+	public function GetEntries()
+	{
+		return $this->entries;
+	}
+
+	/**
 	 * Notify that observable object changed
 	 *
 	 * @param GitPHP_Observable_Interface $object object
@@ -226,52 +236,11 @@
 			return;
 
 		$msg = $args[0];
-		$msg_data = isset($args[1]) ? $args[1] : '';
-		$type = isset($args[2]) ? $args[2] : 'ts';
+		$msg_data = !empty($args[1]) ? $args[1] : '';
+		$type = !empty($args[2]) ? $args[2] : 'ts';
 
 		$this->Log($msg, $msg_data, $type);
 	}
 
-	public function PrintHtml()
-	{
-		if (!$this->enabled) return;
-
-		foreach ($this->entries as $i => $e) {
-			if (strlen($e['value']) > 512) {
-				$contents  = htmlspecialchars(substr($e['value'], 0, 512) . "...");
-				$contents .= "\n\n<i>" . (strlen($e['value']) - 512) . " bytes more in output</i>";
-			} else {
-				$contents = htmlspecialchars($e['value']);
-			}
-			echo "<tr>
-				<td class='debug_key'>$e[name]</td>
-				<td class='debug_value'>
-					" . nl2br($contents) . ($contents != "" ? "<br§ />" : "") . "
-					<span class='debug_toggle'>trace</span>&nbsp;
-					<div class='debug_bt'>$e[bt]</div>
-				</td>
-				<td class='debug_time'>
-					" . ($e['time'] ? sprintf("%.1f", $e['time'] * 1000) : '') . "
-					" . ($e['time'] ? (!empty($e['reltime']) ? " ms from start" : " ms") : '') . "
-				</td>
-			</tr>";
-		}
-	}
-
-	public function PrintHtmlHeader()
-	{
-		if (!$this->enabled) return;
-
-		echo
-<<<HEREDOC
-		<table class="debug"><tbody>
-HEREDOC;
-	}
-
-	public function PrintHtmlFooter()
-	{
-		if (!$this->enabled) return;
-		echo '</tbody></table>';
-	}
 }
 

comments