Skip to content
Snippets Groups Projects
Commit bb17fc30 authored by Olav Morken's avatar Olav Morken
Browse files

Added possibility to log using the php error_log function.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@586 44740490-163a-0410-bde0-09ae8108e29a
parent 159f0789
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,7 @@ $config = array (
*
* Choose logging handler.
*
* Options: [syslog,file]
* Options: [syslog,file,errorlog]
*
*/
'logging.level' => LOG_NOTICE,
......
......@@ -133,6 +133,9 @@ class SimpleSAML_Logger {
} elseif ($handler === 'file') {
require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Logger/LoggingHandlerFile.php');
$sh = new SimpleSAML_Logger_LoggingHandlerFile();
} elseif ($handler === 'errorlog') {
require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Logger/LoggingHandlerErrorLog.php');
$sh = new SimpleSAML_Logger_LoggingHandlerErrorLog();
} else {
throw new Exception('Invalid value for the [logging.handler] configuration option. Unknown handler: ' . $handler);
}
......
<?php
require_once((isset($SIMPLESAML_INCPREFIX)?$SIMPLESAML_INCPREFIX:'') . 'SimpleSAML/Logger.php');
/**
* A class for logging to the default php error log.
*
* @author Lasse Birnbaum Jensen, SDU.
* @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS.
* @package simpleSAMLphp
* @version $ID$
*/
class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_LoggingHandler {
/**
* This array contains the mappings from syslog loglevel to names.
*/
private static $levelNames = array(
LOG_EMERG => 'EMERG',
LOG_ALERT => 'ALERT',
LOG_CRIT => 'CRIT',
LOG_ERR => 'ERR',
LOG_WARNING => 'WARNING',
LOG_NOTICE => 'NOTICE',
LOG_INFO => 'INFO',
LOG_DEBUG => 'DEBUG',
);
function log_internal($level, $string) {
if(array_key_exists($level, self::$levelNames)) {
$levelName = self::$levelNames[$level];
} else {
$levelName = sprintf('UNKNOWN%d', $level);
}
error_log($levelName . ': ' . $string);
}
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment