ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
12namespace Monolog\Handler;
13
16
23{
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}
Formats incoming records into a one-line string.
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)
write(array $record)
{Writes the record down to the log of the implementing handler.void}
getDefaultFormatter()
Gets the default formatter.FormatterInterface
Monolog log channel.
Definition: Logger.php:28
const DEBUG
Detailed debug information.
Definition: Logger.php:32