From 7c9fe02931fa8b8f1060f6f33c903c8830c8599b Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Thu, 4 Jun 2015 08:36:39 +0200 Subject: [PATCH] Add generation time in HTML output --- Lib/Formatter/Html.php | 9 ++++++++- Lib/Logger.php | 10 +++++++--- templates/panel.html | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Lib/Formatter/Html.php b/Lib/Formatter/Html.php index 20ef7c0..47d8013 100644 --- a/Lib/Formatter/Html.php +++ b/Lib/Formatter/Html.php @@ -2,6 +2,8 @@ namespace BSR\Lib\Formatter; +use BSR\Lib\Logger; + class Html extends Formatter { protected static function init() { self::registerFormats(array( @@ -128,9 +130,14 @@ class Html extends Formatter { 'status' => 'info', ); } + $data = Logger::data(); + $context['time'] = $data['time']; $panel = static::template($context, 'panel'); - echo static::template(array('title' => $context['title'], 'content' => $panel)); + echo static::template(array( + 'title' => $context['title'], + 'content' => $panel, + )); } public static function template(array $context = array(), $template = 'layout') { diff --git a/Lib/Logger.php b/Lib/Logger.php index ab239a9..1f73ee1 100644 --- a/Lib/Logger.php +++ b/Lib/Logger.php @@ -62,10 +62,10 @@ class Logger { self::info($data); } - if(Configuration::get('log.verbosity') > Logger::QUIET) { - $time = (microtime(true) - self::$start) * 1000; - self::$data['time'] = round($time, 2).'ms'; + $time = (microtime(true) - self::$start) * 1000; + self::$data['time'] = round($time, 2).'ms'; + if(Configuration::get('log.verbosity') > Logger::QUIET) { $format = Configuration::get('log.format'); $patterns = array_map(function($p) { return "%$p%"; }, array_keys(self::$data)); @@ -78,4 +78,8 @@ class Logger { file_put_contents(Configuration::get('log.file'), $msg, FILE_APPEND | LOCK_EX); } } + + public static function data() { + return self::$data; + } } \ No newline at end of file diff --git a/templates/panel.html b/templates/panel.html index abdf24c..207c655 100644 --- a/templates/panel.html +++ b/templates/panel.html @@ -5,4 +5,7 @@
{{ content }}
+ \ No newline at end of file