summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNozomi Anzai2011-10-11 02:10:52 +0000
committerNozomi Anzai2011-10-11 02:10:52 +0000
commit8c06badefa29b613e3761dbcf5a5d00518199ddd (patch)
tree50dda4e9b107c28aaa495712d115141d7b3c3bb1
parent0b2bed630f8d732327b585048be69e5bcbc8e839 (diff)
separate each parts in log line
-rw-r--r--innerLog.php19
-rw-r--r--templates/innerLog.tpl11
2 files changed, 19 insertions, 11 deletions
diff --git a/innerLog.php b/innerLog.php
index 63d3002..54ed27b 100644
--- a/innerLog.php
+++ b/innerLog.php
@@ -36,7 +36,7 @@ if ($pgpoolLog == '') {
}
$logFile = @file($pgpoolLog);
-if ($logFile == false) {
+if ($logFile == FALSE) {
$errorCode = 'e8001';
$tpl->assign('errorCode', $errorCode);
$tpl->display('innerError.tpl');
@@ -44,11 +44,22 @@ if ($logFile == false) {
}
$logSplitFile = array();
-for($i = 0; $i < count($logFile); $i++) {
- $logFile[$i] = split(' +', $logFile[$i], 6);
+for ($i = 0; $i < count($logFile); $i++) {
+ $words = explode(" ", $logFile[$i]);
+ $words = array_merge(array_diff($words, array("")));
+
+ $logFile[$i] = array('timestamp' => $words[0]. ' '. $words[1],
+ 'level' => $words[2],
+ 'pid' => $words[3]. ' '. $words[4],
+ 'message' => ''
+ );
+
+ for ($j = 5; $j < count($words); $j++) {
+ $logFile[$i]['message'] .= ' '. $words[$j];
+ }
+ $logFile[$i]['message'] = trim($logFile[$i]['message']);
}
$tpl->assign('logFile', $logFile);
$tpl->display('innerLog.tpl');
-
?>
diff --git a/templates/innerLog.tpl b/templates/innerLog.tpl
index d9f89ed..9f071bf 100644
--- a/templates/innerLog.tpl
+++ b/templates/innerLog.tpl
@@ -18,13 +18,10 @@
{else}
<tr class="odd">
{/if}
- <td>{$logFile[num][0]|escape}</td>
- <td>{$logFile[num][1]|escape}</td>
- <td>{$logFile[num][2]|escape}</td>
- <td>{$logFile[num][3]|escape}</td>
- <td>{$logFile[num][4]|escape}</td>
- <td>{$logFile[num][5]|escape}</td>
- <td></td>
+ <td>{$logFile[num].timestamp|escape}</td>
+ <td>{$logFile[num].level|escape}</td>
+ <td>{$logFile[num].pid|escape}</td>
+ <td>{$logFile[num].message|escape}</td>
{/section}
</tbody>
</table>