From 0a45d90ba11d617fc4e4a1929987419a0d61fc28 Mon Sep 17 00:00:00 2001 From: coderkun Date: Wed, 30 Oct 2013 12:17:07 +0100 Subject: [PATCH] disable auto logging to screen for AJAX-requests --- apis/WebApi.inc | 5 +++++ core/Api.inc | 2 +- core/Logger.inc | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apis/WebApi.inc b/apis/WebApi.inc index 28896a30..6851ee2d 100644 --- a/apis/WebApi.inc +++ b/apis/WebApi.inc @@ -37,6 +37,11 @@ // Add routes $this->addRoutes(); + + // Disable screen logging for AJAX requests + if($this->request->getParam(0, 'toplevel') == 'ajax') { + $this->log->disableAutoLogToScreen(); + } } diff --git a/core/Api.inc b/core/Api.inc index 2623bba6..b89b12e7 100644 --- a/core/Api.inc +++ b/core/Api.inc @@ -45,7 +45,7 @@ * * @var Logger */ - private $log; + protected $log; diff --git a/core/Logger.inc b/core/Logger.inc index c96dff0a..b5ac7dc9 100644 --- a/core/Logger.inc +++ b/core/Logger.inc @@ -38,6 +38,13 @@ */ const LOGMODE_PHP = 2; + /** + * Do not auto-log to screen + * + * @var boolean + */ + private $autoLogToScreenDisabled = false; + @@ -76,6 +83,15 @@ } + /** + * Disable logging to screen when the log mode is automatically + * detected. + */ + public function disableAutoLogToScreen() + { + $this->autoLogToScreenDisabled = true; + } + /** @@ -108,7 +124,7 @@ */ private function getAutoLogMode() { - return ($_SERVER['SERVER_ADDR'] == '127.0.0.1') ? self::LOGMODE_SCREEN : self::LOGMODE_PHP; + return ($_SERVER['SERVER_ADDR'] == '127.0.0.1' && !$this->autoLogToScreenDisabled) ? self::LOGMODE_SCREEN : self::LOGMODE_PHP; } }