Skip to content

Commit 5e9e9e9

Browse files
author
redray
committed
Module Monitor: set css class for each line of log, depending on key words in each line
1 parent f061c85 commit 5e9e9e9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

interface/web/monitor/show_log.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,20 @@
125125
if(isset($record['data'])) {
126126
$data = unserialize($record['data']);
127127

128-
$logData = nl2br(htmlspecialchars($data));
128+
$logData = explode("\n", htmlspecialchars($data));
129+
$logDataHtml = '';
130+
/* set css class for each line of log, depending on key words in each line */
131+
foreach($logData as $val) {
132+
if (strpos($val, 'ERROR') !== FALSE) {
133+
$logDataHtml .= "<div class='logerror'>$val</div>";
134+
} elseif (strpos($val, 'WARN') !== FALSE) {
135+
$logDataHtml .= "<div class='logwarn'>$val</div>";
136+
} elseif (strpos($val, 'INFO') !== FALSE) {
137+
$logDataHtml .= "<div class='loginfo'>$val</div>";
138+
} else {
139+
$logDataHtml .= "<div class='log'>$val</div>";
140+
}
141+
}
129142

130143
$app->tpl->setVar("log_data", $logData);
131144
} else {

interface/web/themes/default/css/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ table.list .tbl_col_limit {
438438
font-family: Consolas, "Lucida Console", "Courier New", monospace;
439439
font-size: 0.9em;
440440
}
441+
.codeview .logerror { background: rgb(255,0,0); }
442+
.codeview .logwarn { background: rgb(255,204,0); }
443+
.codeview .loginfo { background: rgb(153,204,255); }
441444
/* Lists */
442445
table.list {
443446
width: 100%;

0 commit comments

Comments
 (0)