summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php
diff options
context:
space:
mode:
authorOlav Morken <olav.morken@uninett.no>2008-06-03 05:19:09 +0000
committerOlav Morken <olav.morken@uninett.no>2008-06-03 05:19:09 +0000
commitbb17fc30faca41ada4d66ffe69c9a973ab5f2d30 (patch)
tree979b5dcdbf560be259934f24a5b91b2771374929 /lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php
parent159f0789fbab71073d743157b832230cb1d5ee60 (diff)
downloadsimplesamlphp-bb17fc30faca41ada4d66ffe69c9a973ab5f2d30.zip
simplesamlphp-bb17fc30faca41ada4d66ffe69c9a973ab5f2d30.tar.gz
simplesamlphp-bb17fc30faca41ada4d66ffe69c9a973ab5f2d30.tar.bz2
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
Diffstat (limited to 'lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php')
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php
new file mode 100644
index 0000000..bf52f86
--- /dev/null
+++ b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php
@@ -0,0 +1,42 @@
+<?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