ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  } else {
74  $this->facilities['local0'] = 128; // LOG_LOCAL0
75  $this->facilities['local1'] = 136; // LOG_LOCAL1
76  $this->facilities['local2'] = 144; // LOG_LOCAL2
77  $this->facilities['local3'] = 152; // LOG_LOCAL3
78  $this->facilities['local4'] = 160; // LOG_LOCAL4
79  $this->facilities['local5'] = 168; // LOG_LOCAL5
80  $this->facilities['local6'] = 176; // LOG_LOCAL6
81  $this->facilities['local7'] = 184; // LOG_LOCAL7
82  }
83 
84  // convert textual description of facility to syslog constant
85  if (array_key_exists(strtolower($facility), $this->facilities)) {
86  $facility = $this->facilities[strtolower($facility)];
87  } elseif (!in_array($facility, array_values($this->facilities), true)) {
88  throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
89  }
90 
91  $this->facility = $facility;
92  }
93 
97  protected function getDefaultFormatter()
98  {
99  return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
100  }
101 }
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
Create styles array
The data for the language used.
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.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
const INFO
Interesting events.
Definition: Logger.php:39