disable auto logging to screen for AJAX-requests

This commit is contained in:
coderkun 2013-10-30 12:17:07 +01:00
parent d9d85e2306
commit 0a45d90ba1
3 changed files with 23 additions and 2 deletions

View file

@ -37,6 +37,11 @@
// Add routes
$this->addRoutes();
// Disable screen logging for AJAX requests
if($this->request->getParam(0, 'toplevel') == 'ajax') {
$this->log->disableAutoLogToScreen();
}
}

View file

@ -45,7 +45,7 @@
*
* @var Logger
*/
private $log;
protected $log;

View file

@ -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;
}
}