diff options
author | Jaime Perez <jaime.perez@uninett.no> | 2014-06-17 16:18:08 +0200 |
---|---|---|
committer | Jaime Perez <jaime.perez@uninett.no> | 2014-06-17 16:18:08 +0200 |
commit | 0e2f2ec441b25dfa3d5136e400b324dc54310f0b (patch) | |
tree | 393a7106b71cb00f5c36023f2a10ceec0a52f9ad /lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php | |
parent | 246f901962c22811e3adef88b9b9aab6ea4412f9 (diff) | |
download | simplesamlphp-0e2f2ec441b25dfa3d5136e400b324dc54310f0b.zip simplesamlphp-0e2f2ec441b25dfa3d5136e400b324dc54310f0b.tar.gz simplesamlphp-0e2f2ec441b25dfa3d5136e400b324dc54310f0b.tar.bz2 |
Add a new 'logging.format' option to control the formatting of the logs.
Diffstat (limited to 'lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php')
-rw-r--r-- | lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php index 0a687ee..cd9404d 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php @@ -26,18 +26,29 @@ class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_Logg ); - function log_internal($level, $string) {
- $config = SimpleSAML_Configuration::getInstance();
- assert($config instanceof SimpleSAML_Configuration);
- $processname = $config->getString('logging.processname','simpleSAMLphp');
-
+ 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); } - error_log($processname.' - '.$levelName . ': ' . $string); + $formats = array('%process', '%level'); + $replacements = array($processname, $levelName); + $string = str_replace($formats, $replacements, $string); + $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string); + $string = trim($string); + + error_log($string); } } |