diff options
Diffstat (limited to 'lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php')
-rw-r--r-- | lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php index cd9404d..7dcfc7b 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php @@ -9,38 +9,53 @@ * @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( - SimpleSAML_Logger::EMERG => 'EMERG', - SimpleSAML_Logger::ALERT => 'ALERT', - SimpleSAML_Logger::CRIT => 'CRIT', - SimpleSAML_Logger::ERR => 'ERR', - SimpleSAML_Logger::WARNING => 'WARNING', - SimpleSAML_Logger::NOTICE => 'NOTICE', - SimpleSAML_Logger::INFO => 'INFO', - SimpleSAML_Logger::DEBUG => 'DEBUG', - ); - - - function setLogFormat($format) { +class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_LoggingHandler +{ + + /** + * This array contains the mappings from syslog loglevel to names. + */ + private static $levelNames = array( + SimpleSAML_Logger::EMERG => 'EMERG', + SimpleSAML_Logger::ALERT => 'ALERT', + SimpleSAML_Logger::CRIT => 'CRIT', + SimpleSAML_Logger::ERR => 'ERR', + SimpleSAML_Logger::WARNING => 'WARNING', + SimpleSAML_Logger::NOTICE => 'NOTICE', + SimpleSAML_Logger::INFO => 'INFO', + SimpleSAML_Logger::DEBUG => 'DEBUG', + ); + private $format; + + + /** + * Set the format desired for the logs. + * + * @param string $format The format used for logs. + */ + public function setLogFormat($format) + { $this->format = $format; } - function log_internal($level, $string) { - $config = SimpleSAML_Configuration::getInstance(); - assert($config instanceof SimpleSAML_Configuration); - $processname = $config->getString('logging.processname','simpleSAMLphp'); - - if(array_key_exists($level, self::$levelNames)) { - $levelName = self::$levelNames[$level]; - } else { - $levelName = sprintf('UNKNOWN%d', $level); - } + /** + * Log a message to syslog. + * + * @param int $level The log level. + * @param string $string The formatted message to log. + */ + public function log($level, $string) + { + $config = SimpleSAML_Configuration::getInstance(); + assert($config instanceof SimpleSAML_Configuration); + $processname = $config->getString('logging.processname', 'simpleSAMLphp'); + + if (array_key_exists($level, self::$levelNames)) { + $levelName = self::$levelNames[$level]; + } else { + $levelName = sprintf('UNKNOWN%d', $level); + } $formats = array('%process', '%level'); $replacements = array($processname, $levelName); @@ -48,8 +63,6 @@ class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_Logg $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string); $string = trim($string); - error_log($string); - } + error_log($string); + } } - -?>
\ No newline at end of file |