diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index bd54a9a814db11d84d526670d7bcb81e49d60e70..75ee11f9657fc44b3b4e75f5823164de53383427 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -196,15 +196,25 @@ class SimpleSAML_Error_Exception extends Exception /** * Print the backtrace to the log if the 'debug' option is enabled in the configuration. */ - protected function logBacktrace() + protected function logBacktrace($level = \SimpleSAML\Logger::DEBUG) { if (!SimpleSAML_Configuration::getInstance()->getBoolean('debug', false)) { return; } $backtrace = $this->formatBacktrace(); + + $callback = array('\SimpleSAML\Logger'); + $functions = array( + \SimpleSAML\Logger::ERR => 'error', + \SimpleSAML\Logger::WARNING => 'warning', + \SimpleSAML\Logger::INFO => 'info', + \SimpleSAML\Logger::DEBUG => 'debug', + ); + $callback[] = $functions[$level]; + foreach ($backtrace as $line) { - SimpleSAML\Logger::debug($line); + call_user_func($callback, $line); } } @@ -224,7 +234,7 @@ class SimpleSAML_Error_Exception extends Exception SimpleSAML\Logger::INFO => 'logInfo', SimpleSAML\Logger::DEBUG => 'logDebug', ); - call_user_func(array($this, $fn[$default_level])); + call_user_func(array($this, $fn[$default_level]), $default_level); } @@ -236,7 +246,7 @@ class SimpleSAML_Error_Exception extends Exception public function logError() { SimpleSAML\Logger::error($this->getClass().': '.$this->getMessage()); - $this->logBacktrace(); + $this->logBacktrace(\SimpleSAML\Logger::ERR); } @@ -248,7 +258,7 @@ class SimpleSAML_Error_Exception extends Exception public function logWarning() { SimpleSAML\Logger::warning($this->getClass().': '.$this->getMessage()); - $this->logBacktrace(); + $this->logBacktrace(\SimpleSAML\Logger::WARNING); } @@ -260,7 +270,7 @@ class SimpleSAML_Error_Exception extends Exception public function logInfo() { SimpleSAML\Logger::info($this->getClass().': '.$this->getMessage()); - $this->logBacktrace(); + $this->logBacktrace(\SimpleSAML\Logger::INFO); } @@ -272,7 +282,7 @@ class SimpleSAML_Error_Exception extends Exception public function logDebug() { SimpleSAML\Logger::debug($this->getClass().': '.$this->getMessage()); - $this->logBacktrace(); + $this->logBacktrace(\SimpleSAML\Logger::DEBUG); }