ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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. 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...
 
 detectAndCleanUtf8 (&$data)
 Detect invalid UTF-8 string characters and convert to valid UTF-8. 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 ($e)
 
 toJson ($data, $ignoreErrors=false)
 Return the JSON representation of a value. More...
 

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 () 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
}

Implements Monolog\Formatter\FormatterInterface.

Definition at line 44 of file WildfireFormatter.php.

References $file, $message, $type, array, Monolog\Formatter\WildfireFormatter\normalize(), and Monolog\Formatter\NormalizerFormatter\toJson().

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  }
$type
catch(Exception $e) $message
Create styles array
The data for the language used.
toJson($data, $ignoreErrors=false)
Return the JSON representation of a value.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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

Implements Monolog\Formatter\FormatterInterface.

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

Definition at line 105 of file WildfireFormatter.php.

References $data.

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

106  {
107  if (is_object($data) && !$data instanceof \DateTime) {
108  return $data;
109  }
110 
111  return parent::normalize($data);
112  }
+ Here is the caller graph for this function:

Field Documentation

◆ $logLevels

Monolog\Formatter\WildfireFormatter::$logLevels
private
Initial value:
Logger::DEBUG => 'LOG',
Logger::INFO => 'INFO',
Logger::NOTICE => 'INFO',
Logger::WARNING => 'WARN',
Logger::ERROR => 'ERROR',
Logger::CRITICAL => 'ERROR',
Logger::ALERT => 'ERROR',
Logger::EMERGENCY => 'ERROR',
)

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: