Commit 5e9e9e9c authored by redray's avatar redray
Browse files

Module Monitor: set css class for each line of log, depending on key words in each line

parent f061c857
...@@ -125,7 +125,20 @@ $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE t ...@@ -125,7 +125,20 @@ $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE t
if(isset($record['data'])) { if(isset($record['data'])) {
$data = unserialize($record['data']); $data = unserialize($record['data']);
$logData = nl2br(htmlspecialchars($data)); $logData = explode("\n", htmlspecialchars($data));
$logDataHtml = '';
/* set css class for each line of log, depending on key words in each line */
foreach($logData as $val) {
if (strpos($val, 'ERROR') !== FALSE) {
$logDataHtml .= "<div class='logerror'>$val</div>";
} elseif (strpos($val, 'WARN') !== FALSE) {
$logDataHtml .= "<div class='logwarn'>$val</div>";
} elseif (strpos($val, 'INFO') !== FALSE) {
$logDataHtml .= "<div class='loginfo'>$val</div>";
} else {
$logDataHtml .= "<div class='log'>$val</div>";
}
}
$app->tpl->setVar("log_data", $logData); $app->tpl->setVar("log_data", $logData);
} else { } else {
......
...@@ -438,6 +438,9 @@ table.list .tbl_col_limit { ...@@ -438,6 +438,9 @@ table.list .tbl_col_limit {
font-family: Consolas, "Lucida Console", "Courier New", monospace; font-family: Consolas, "Lucida Console", "Courier New", monospace;
font-size: 0.9em; font-size: 0.9em;
} }
.codeview .logerror { background: rgb(255,0,0); }
.codeview .logwarn { background: rgb(255,204,0); }
.codeview .loginfo { background: rgb(153,204,255); }
/* Lists */ /* Lists */
table.list { table.list {
width: 100%; width: 100%;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment