ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
AbstractSyslogHandler.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Handler;
13 
14 use Monolog\Logger;
16 
21 {
22  protected $facility;
23 
27  protected $logLevels = array(
28  Logger::DEBUG => LOG_DEBUG,
29  Logger::INFO => LOG_INFO,
30  Logger::NOTICE => LOG_NOTICE,
31  Logger::WARNING => LOG_WARNING,
32  Logger::ERROR => LOG_ERR,
33  Logger::CRITICAL => LOG_CRIT,
34  Logger::ALERT => LOG_ALERT,
35  Logger::EMERGENCY => LOG_EMERG,
36  );
37 
41  protected $facilities = array(
42  'auth' => LOG_AUTH,
43  'authpriv' => LOG_AUTHPRIV,
44  'cron' => LOG_CRON,
45  'daemon' => LOG_DAEMON,
46  'kern' => LOG_KERN,
47  'lpr' => LOG_LPR,
48  'mail' => LOG_MAIL,
49  'news' => LOG_NEWS,
50  'syslog' => LOG_SYSLOG,
51  'user' => LOG_USER,
52  'uucp' => LOG_UUCP,
53  );
54 
60  public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
61  {
62  parent::__construct($level, $bubble);
63 
64  if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
65  $this->facilities['local0'] = LOG_LOCAL0;
66  $this->facilities['local1'] = LOG_LOCAL1;
67  $this->facilities['local2'] = LOG_LOCAL2;
68  $this->facilities['local3'] = LOG_LOCAL3;
69  $this->facilities['local4'] = LOG_LOCAL4;
70  $this->facilities['local5'] = LOG_LOCAL5;
71  $this->facilities['local6'] = LOG_LOCAL6;
72  $this->facilities['local7'] = LOG_LOCAL7;
73  }
74 
75  // convert textual description of facility to syslog constant
76  if (array_key_exists(strtolower($facility), $this->facilities)) {
77  $facility = $this->facilities[strtolower($facility)];
78  } elseif (!in_array($facility, array_values($this->facilities), true)) {
79  throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
80  }
81 
82  $this->facility = $facility;
83  }
84 
88  protected function getDefaultFormatter()
89  {
90  return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
91  }
92 }
const NOTICE
Uncommon events.
Definition: Logger.php:44
const DEBUG
Detailed debug information.
Definition: Logger.php:32
$facilities
List of valid log facility names.
const ERROR
Runtime errors.
Definition: Logger.php:57
Base Handler class providing the Handler structure.
$logLevels
Translates Monolog log levels to syslog log priorities.
__construct($facility=LOG_USER, $level=Logger::DEBUG, $bubble=true)
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
const EMERGENCY
Urgent alert.
Definition: Logger.php:77
const CRITICAL
Critical conditions.
Definition: Logger.php:64
const ALERT
Action must be taken immediately.
Definition: Logger.php:72
Formats incoming records into a one-line string.
const INFO
Interesting events.
Definition: Logger.php:39