ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ErrorLogHandler.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 
15 use Monolog\Logger;
16 
23 {
24  const OPERATING_SYSTEM = 0;
25  const SAPI = 4;
26 
27  protected $messageType;
28  protected $expandNewlines;
29 
36  public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false)
37  {
38  parent::__construct($level, $bubble);
39 
40  if (false === in_array($messageType, self::getAvailableTypes())) {
41  $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true));
42  throw new \InvalidArgumentException($message);
43  }
44 
45  $this->messageType = $messageType;
46  $this->expandNewlines = $expandNewlines;
47  }
48 
52  public static function getAvailableTypes()
53  {
54  return array(
55  self::OPERATING_SYSTEM,
56  self::SAPI,
57  );
58  }
59 
63  protected function getDefaultFormatter()
64  {
65  return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%');
66  }
67 
71  protected function write(array $record)
72  {
73  if ($this->expandNewlines) {
74  $lines = preg_split('{[\r\n]+}', (string) $record['formatted']);
75  foreach ($lines as $line) {
76  error_log($line, $this->messageType);
77  }
78  } else {
79  error_log((string) $record['formatted'], $this->messageType);
80  }
81  }
82 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
Base Handler class providing the Handler structure.
Stores to PHP error_log() handler.
__construct($messageType=self::OPERATING_SYSTEM, $level=Logger::DEBUG, $bubble=true, $expandNewlines=false)
Create styles array
The data for the language used.
Formats incoming records into a one-line string.