ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ChromePHPFormatter.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 
13 
14 use Monolog\Logger;
15 
22 {
26  private $logLevels = array(
27  Logger::DEBUG => 'log',
28  Logger::INFO => 'info',
29  Logger::NOTICE => 'info',
30  Logger::WARNING => 'warn',
31  Logger::ERROR => 'error',
32  Logger::CRITICAL => 'error',
33  Logger::ALERT => 'error',
34  Logger::EMERGENCY => 'error',
35  );
36 
40  public function format(array $record)
41  {
42  // Retrieve the line and file if set and remove them from the formatted extra
43  $backtrace = 'unknown';
44  if (isset($record['extra']['file'], $record['extra']['line'])) {
45  $backtrace = $record['extra']['file'].' : '.$record['extra']['line'];
46  unset($record['extra']['file'], $record['extra']['line']);
47  }
48 
49  $message = array('message' => $record['message']);
50  if ($record['context']) {
51  $message['context'] = $record['context'];
52  }
53  if ($record['extra']) {
54  $message['extra'] = $record['extra'];
55  }
56  if (count($message) === 1) {
57  $message = reset($message);
58  }
59 
60  return array(
61  $record['channel'],
62  $message,
63  $backtrace,
64  $this->logLevels[$record['level']],
65  );
66  }
67 
68  public function formatBatch(array $records)
69  {
70  $formatted = array();
71 
72  foreach ($records as $record) {
73  $formatted[] = $this->format($record);
74  }
75 
76  return $formatted;
77  }
78 }
const NOTICE
Uncommon events.
Definition: Logger.php:45
const DEBUG
Detailed debug information.
Definition: Logger.php:33
Formats a log message according to the ChromePHP array format.
const ERROR
Runtime errors.
Definition: Logger.php:58
$records
Definition: simple_test.php:22
$logLevels
Translates Monolog log levels to Wildfire levels.
catch(Exception $e) $message
format(array $record)
{Formats a log record.A record to format mixed The formatted record}
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
const EMERGENCY
Urgent alert.
Definition: Logger.php:78
const CRITICAL
Critical conditions.
Definition: Logger.php:65
const ALERT
Action must be taken immediately.
Definition: Logger.php:73
formatBatch(array $records)
Formats a set of log records.
const INFO
Interesting events.
Definition: Logger.php:40