From 808a9df13e3df8e93b0388b1dfb9529c6d162efb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 1 Jun 2018 11:06:27 +0200 Subject: [PATCH] StartupLogRenderer: parse lines with timestamps This is required to support Icinga v2.9.0 fixes #1478 --- doc/82-Changelog.md | 11 +++++------ library/Director/StartupLogRenderer.php | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index 73e70071..af4b744c 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -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 diff --git a/library/Director/StartupLogRenderer.php b/library/Director/StartupLogRenderer.php index c079437f..44bb1b0d 100644 --- a/library/Director/StartupLogRenderer.php +++ b/library/Director/StartupLogRenderer.php @@ -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 ); } - $lines[] .= $line; + if ($time === null) { + $lines[] .= $line; + } else { + $lines[] .= "[$time] $line"; + } } return implode("\n", $lines); }