ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ErrorLogLoggingHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace SimpleSAML\Logger;
4 
6 
16 {
17 
21  private static $levelNames = array(
22  Logger::EMERG => 'EMERG',
23  Logger::ALERT => 'ALERT',
24  Logger::CRIT => 'CRIT',
25  Logger::ERR => 'ERR',
26  Logger::WARNING => 'WARNING',
27  Logger::NOTICE => 'NOTICE',
28  Logger::INFO => 'INFO',
29  Logger::DEBUG => 'DEBUG',
30  );
31 
37  private $processname;
38 
39 
46  {
47  $this->processname = $config->getString('logging.processname', 'SimpleSAMLphp');
48  }
49 
50 
56  public function setLogFormat($format)
57  {
58  // we don't need the format here
59  }
60 
61 
68  public function log($level, $string)
69  {
70  if (array_key_exists($level, self::$levelNames)) {
71  $levelName = self::$levelNames[$level];
72  } else {
73  $levelName = sprintf('UNKNOWN%d', $level);
74  }
75 
76  $formats = array('%process', '%level');
77  $replacements = array($this->processname, $levelName);
78  $string = str_replace($formats, $replacements, $string);
79  $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string);
80  $string = trim($string);
81 
82  error_log($string);
83  }
84 }
setLogFormat($format)
Set the format desired for the logs.
log($level, $string)
Log a message to syslog.
__construct(\SimpleSAML_Configuration $config)
ErrorLogLoggingHandler constructor.
static $levelNames
This array contains the mappings from syslog log level to names.
Create styles array
The data for the language used.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
static $format
Definition: Logger.php:104
$formats
Definition: date.php:77