ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SyslogLoggingHandler.php
Go to the documentation of this file.
1<?php
2
3namespace SimpleSAML\Logger;
4
6
15{
16 private $isWindows = false;
17 private $format;
18
19
24 {
25 $facility = $config->getInteger('logging.facility', defined('LOG_LOCAL5') ? constant('LOG_LOCAL5') : LOG_USER);
26
27 $processname = $config->getString('logging.processname', 'SimpleSAMLphp');
28
29 // Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems
31 $this->isWindows = true;
32 $facility = LOG_USER;
33 }
34
35 openlog($processname, LOG_PID, $facility);
36 }
37
38
44 public function setLogFormat($format)
45 {
46 $this->format = $format;
47 }
48
49
56 public function log($level, $string)
57 {
58 // changing log level to supported levels if OS is Windows
59 if ($this->isWindows) {
60 if ($level <= 4) {
61 $level = LOG_ERR;
62 } else {
63 $level = LOG_INFO;
64 }
65 }
66
67 $formats = array('%process', '%level');
68 $replacements = array('', $level);
69 $string = str_replace($formats, $replacements, $string);
70 $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string);
71 $string = trim($string);
72
73 syslog($level, $string);
74 }
75}
An exception for terminatinating execution or to throw for unit testing.
setLogFormat($format)
Set the format desired for the logs.
__construct(\SimpleSAML_Configuration $config)
Build a new logging handler based on syslog.
log($level, $string)
Log a message to syslog.
static getOS()
This function returns the Operating System we are running on.
Definition: System.php:29
$formats
Definition: date.php:77
$config
Definition: bootstrap.php:15