From 89ca42da549bc399f21e4890f95873655665f896 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 24 Oct 2018 15:50:48 +0200 Subject: [PATCH] [index] Always write exceptions to error.log Exceptions are reported to users, but they do not necessarily appear in the error log on the server. Using 'error_log' we can explicitly write exceptions and error messages to the log file, using the standard PHP message format. For more information see https://stackoverflow.com/a/26867035 --- index.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.php b/index.php index 037b8b09..69e5009d 100644 --- a/index.php +++ b/index.php @@ -262,6 +262,8 @@ try { 'icon' => $bridge->getIcon() ); } catch(Error $e) { + error_log($e); + $item = array(); // Create "new" error message every 24 hours @@ -280,6 +282,8 @@ try { $items[] = $item; } catch(Exception $e) { + error_log($e); + $item = array(); // Create "new" error message every 24 hours @@ -309,10 +313,12 @@ try { $format->setLastModified($cache->getTime()); $format->display(); } catch(Error $e) { + error_log($e); http_response_code($e->getCode()); header('Content-Type: text/html'); die(buildTransformException($e, $bridge)); } catch(Exception $e) { + error_log($e); http_response_code($e->getCode()); header('Content-Type: text/html'); die(buildTransformException($e, $bridge)); @@ -321,9 +327,11 @@ try { echo BridgeList::create($whitelist_selection, $showInactive); } } catch(HttpException $e) { + error_log($e); http_response_code($e->getCode()); header('Content-Type: text/plain'); die($e->getMessage()); } catch(\Exception $e) { + error_log($e); die($e->getMessage()); }