ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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']) && isset($record['extra']['line'])) {
45 $backtrace = $record['extra']['file'].' : '.$record['extra']['line'];
46 unset($record['extra']['file']);
47 unset($record['extra']['line']);
48 }
49
50 $message = array('message' => $record['message']);
51 if ($record['context']) {
52 $message['context'] = $record['context'];
53 }
54 if ($record['extra']) {
55 $message['extra'] = $record['extra'];
56 }
57 if (count($message) === 1) {
58 $message = reset($message);
59 }
60
61 return array(
62 $record['channel'],
63 $message,
64 $backtrace,
65 $this->logLevels[$record['level']],
66 );
67 }
68
69 public function formatBatch(array $records)
70 {
71 $formatted = array();
72
73 foreach ($records as $record) {
74 $formatted[] = $this->format($record);
75 }
76
77 return $formatted;
78 }
79}
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
$records
Definition: simple_test.php:17