ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Formatter\WildfireFormatter Class Reference

Serializes a log message according to Wildfire's header requirements. More...

+ Inheritance diagram for Monolog\Formatter\WildfireFormatter:
+ Collaboration diagram for Monolog\Formatter\WildfireFormatter:

Public Member Functions

 format (array $record)
 {{Formats a log record.
Parameters
array$recordA record to format
Returns
mixed The formatted record
}} More...
 
 formatBatch (array $records)
 {{Formats a set of log records.
Parameters
array$recordsA set of records to format
Returns
mixed The formatted set of records
}} More...
 
- Public Member Functions inherited from Monolog\Formatter\NormalizerFormatter
 __construct ($dateFormat=null)
 
 format (array $record)
 {Formats a log record.
Parameters
array$recordA record to format
Returns
mixed The formatted record
} More...
 
 formatBatch (array $records)
 {Formats a set of log records.
Parameters
array$recordsA set of records to format
Returns
mixed The formatted set of records
} More...
 
 format (array $record)
 Formats a log record. More...
 
 formatBatch (array $records)
 Formats a set of log records. More...
 

Data Fields

const TABLE = 'table'
 
- Data Fields inherited from Monolog\Formatter\NormalizerFormatter
const SIMPLE_DATE = "Y-m-d H:i:s"
 

Protected Member Functions

 normalize ($data)
 
- Protected Member Functions inherited from Monolog\Formatter\NormalizerFormatter
 normalize ($data)
 
 normalizeException (Exception $e)
 
 toJson ($data, $ignoreErrors=false)
 

Private Attributes

 $logLevels
 Translates Monolog log levels to Wildfire levels. More...
 

Additional Inherited Members

- Protected Attributes inherited from Monolog\Formatter\NormalizerFormatter
 $dateFormat
 

Detailed Description

Serializes a log message according to Wildfire's header requirements.

Author
Eric Clemmons (@ericclemmons) eric@.nosp@m.uxdr.nosp@m.iven..nosp@m.com
Christophe Coevoet stof@.nosp@m.notk.nosp@m..org
Kirill chEbba Chebunin iam@c.nosp@m.hebb.nosp@m.a.org

Definition at line 23 of file WildfireFormatter.php.

Member Function Documentation

◆ format()

Monolog\Formatter\WildfireFormatter::format ( array  $record)

{{Formats a log record.

Parameters
array$recordA record to format
Returns
mixed The formatted record
}}

Reimplemented from Monolog\Formatter\NormalizerFormatter.

Definition at line 44 of file WildfireFormatter.php.

45 {
46 // Retrieve the line and file if set and remove them from the formatted extra
47 $file = $line = '';
48 if (isset($record['extra']['file'])) {
49 $file = $record['extra']['file'];
50 unset($record['extra']['file']);
51 }
52 if (isset($record['extra']['line'])) {
53 $line = $record['extra']['line'];
54 unset($record['extra']['line']);
55 }
56
57 $record = $this->normalize($record);
58 $message = array('message' => $record['message']);
59 $handleError = false;
60 if ($record['context']) {
61 $message['context'] = $record['context'];
62 $handleError = true;
63 }
64 if ($record['extra']) {
65 $message['extra'] = $record['extra'];
66 $handleError = true;
67 }
68 if (count($message) === 1) {
69 $message = reset($message);
70 }
71
72 if (isset($record['context'][self::TABLE])) {
73 $type = 'TABLE';
74 $label = $record['channel'] .': '. $record['message'];
75 $message = $record['context'][self::TABLE];
76 } else {
77 $type = $this->logLevels[$record['level']];
78 $label = $record['channel'];
79 }
80
81 // Create JSON object describing the appearance of the message in the console
82 $json = $this->toJson(array(
83 array(
84 'Type' => $type,
85 'File' => $file,
86 'Line' => $line,
87 'Label' => $label,
88 ),
89 $message,
90 ), $handleError);
91
92 // The message itself is a serialization of the above JSON object + it's length
93 return sprintf(
94 '%s|%s|',
95 strlen($json),
96 $json
97 );
98 }
print $file

References $file, Monolog\Formatter\WildfireFormatter\normalize(), Monolog\Formatter\WildfireFormatter\TABLE, and Monolog\Formatter\NormalizerFormatter\toJson().

+ Here is the call graph for this function:

◆ formatBatch()

Monolog\Formatter\WildfireFormatter::formatBatch ( array  $records)

{{Formats a set of log records.

Parameters
array$recordsA set of records to format
Returns
mixed The formatted set of records
}}

Reimplemented from Monolog\Formatter\NormalizerFormatter.

Definition at line 100 of file WildfireFormatter.php.

101 {
102 throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter');
103 }

◆ normalize()

Monolog\Formatter\WildfireFormatter::normalize (   $data)
protected

Reimplemented from Monolog\Formatter\NormalizerFormatter.

Definition at line 105 of file WildfireFormatter.php.

106 {
107 if (is_object($data) && !$data instanceof \DateTime) {
108 return $data;
109 }
110
111 return parent::normalize($data);
112 }
$data

References $data.

Referenced by Monolog\Formatter\WildfireFormatter\format().

+ Here is the caller graph for this function:

Field Documentation

◆ $logLevels

Monolog\Formatter\WildfireFormatter::$logLevels
private
Initial value:
= array(
Logger::DEBUG => 'LOG',
Logger::INFO => 'INFO',
Logger::NOTICE => 'INFO',
Logger::WARNING => 'WARN',
Logger::ERROR => 'ERROR',
Logger::CRITICAL => 'ERROR',
Logger::ALERT => 'ERROR',
Logger::EMERGENCY => 'ERROR',
)
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

Translates Monolog log levels to Wildfire levels.

Definition at line 30 of file WildfireFormatter.php.

◆ TABLE

const Monolog\Formatter\WildfireFormatter::TABLE = 'table'

The documentation for this class was generated from the following file: