summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Pérez <jaime.perez@uninett.no>2016-08-10 13:52:11 +0200
committerJaime Pérez <jaime.perez@uninett.no>2016-08-10 13:52:41 +0200
commit0858c10c8724c5e434fe949b2c9f96719a9de246 (patch)
treec483f73670e9fdd2b272e392bb343cd175d0c9eb /lib/SimpleSAML
parentc08ee8976f89218e7c585ea94924a7802b4ac05c (diff)
downloadsimplesamlphp-0858c10c8724c5e434fe949b2c9f96719a9de246.zip
simplesamlphp-0858c10c8724c5e434fe949b2c9f96719a9de246.tar.gz
simplesamlphp-0858c10c8724c5e434fe949b2c9f96719a9de246.tar.bz2
Log backtraces with the same log level as the error messages, whatever that is.
It's not very useful to log backtraces always as debug, since that implies getting all the log messages, while backtraces would still help debug a particular error.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Error/Exception.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php
index bd54a9a..75ee11f 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);
}