diff options
Diffstat (limited to 'lib/SimpleSAML/Utilities.php')
-rw-r--r-- | lib/SimpleSAML/Utilities.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 5b78098..02057ee 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -1906,6 +1906,35 @@ class SimpleSAML_Utilities { SimpleSAML_Utilities::redirect($url); } + + /** + * Helper function to log messages that we send or receive. + * + * @param string $message The message, as an XML string. + * @param string $type Whether this message is sent or received. + */ + public static function debugMessage($message, $type) { + assert('is_string($message)'); + assert('$type === "out" || $type === "in"'); + + $globalConfig = SimpleSAML_Configuration::getInstance(); + if (!$globalConfig->getBoolean('debug', FALSE)) { + /* Message debug disabled. */ + return; + } + + if ($type === 'in') { + SimpleSAML_Logger::debug('Received message:'); + } else { + SimpleSAML_Logger::debug('Sending message:'); + } + + $str = self::formatXMLString($message); + foreach (explode("\n", $str) as $line) { + SimpleSAML_Logger::debug($line); + } + } + } ?>
\ No newline at end of file |