StartupLogRenderer: parse lines with timestamps

This is required to support Icinga v2.9.0

fixes #1478
This commit is contained in:
Thomas Gelf 2018-06-01 11:06:27 +02:00
parent 31a6ab0cf2
commit 808a9df13e
2 changed files with 19 additions and 7 deletions

View File

@ -17,6 +17,11 @@ before switching to a new version.
### Icinga Configuration
* FEATURE: Add 'is false (or not set)' condition for apply rules (#1436)
* FEATURE: support flapping settings for Icinga >= 2.8.0 (#330)
* FEATURE: include all itl packages in Linux Agent sample config (#1450)
* FEATURE: it's now possible to blacklist inherited or applied Services on
single hosts (#907)
* FEATURE: timestamped startup log rendering for upcoming Icinga v2.9.0 (#1478)
### User Interface
* FEATURE: Admins have now access to JSON download links in many places
@ -51,12 +56,6 @@ before switching to a new version.
* FEATURE: Html/Attribute now allows boolean properties
* FEATURE: Html/Attribute allows colons in attribute names (required for SVGs)
### Icinga Configuration
* FEATURE: support flapping settings for Icinga >= 2.8.0 (#330)
* FEATURE: include all itl packages in Linux Agent sample config (#1450)
* FEATURE: it's now possible to blacklist inherited or applied Services on
single hosts (#907)
1.4.3
-----
### Fixed issues

View File

@ -31,6 +31,15 @@ class StartupLogRenderer implements ValidHtml
$markReplace = ' ^';
foreach (preg_split('/\n/', $log) as $line) {
if (preg_match('/^\[([\d\s\:\+\-]+)\]\s/', $line, $m)) {
$time = $m[1];
// TODO: we might use new DateTime($time) and show a special "timeAgo"
// format - but for now this should suffice.
$line = substr($line, strpos($line, ']') + 2);
} else {
$time = null;
}
if (preg_match($sevPattern, $line, $m)) {
$severity = $m[1];
$line = preg_replace(
@ -70,7 +79,11 @@ class StartupLogRenderer implements ValidHtml
);
}
if ($time === null) {
$lines[] .= $line;
} else {
$lines[] .= "[$time] $line";
}
}
return implode("\n", $lines);
}