ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
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'],
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}
An exception for terminatinating execution or to throw for unit testing.
Formats a log message according to the ChromePHP array format.
format(array $record)
{Formats a log record.mixed The formatted record}
formatBatch(array $records)
Formats a set of log records.
$logLevels
Translates Monolog log levels to Wildfire levels.
Monolog log channel.
Definition: Logger.php:28
const EMERGENCY
Urgent alert.
Definition: Logger.php:77
const ERROR
Runtime errors.
Definition: Logger.php:57
const CRITICAL
Critical conditions.
Definition: Logger.php:64
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
const INFO
Interesting events.
Definition: Logger.php:39
const DEBUG
Detailed debug information.
Definition: Logger.php:32
const NOTICE
Uncommon events.
Definition: Logger.php:44
const ALERT
Action must be taken immediately.
Definition: Logger.php:72
catch(Exception $e) $message
$records
Definition: simple_test.php:22