MediaWiki  master
MediaWiki\Logger\Monolog\AvroFormatter Class Reference

Log message formatter that uses the apache Avro format. More...

Inheritance diagram for MediaWiki\Logger\Monolog\AvroFormatter:
Collaboration diagram for MediaWiki\Logger\Monolog\AvroFormatter:

Public Member Functions

 __construct (array $schemas)
 
 format (array $record)
 Formats the record context into a binary string per the schema configured for the records channel. More...
 
 formatBatch (array $records)
 Format a set of records into a list of binary strings conforming to the configured schema. More...
 
 getSchemaRevisionId ( $channel)
 Get the writer for the named channel. More...
 

Protected Member Functions

 getSchema ( $channel)
 Get the writer for the named channel. More...
 

Protected Attributes

AvroIOBinaryEncoder $encoder
 
AvroStringIO $io
 
array $schemas
 Map from schema name to schema definition. More...
 
AvroIODatumWriter $writer
 

Private Member Functions

 encodeLong ( $id)
 convert an integer to a 64bits big endian long (Java compatible) NOTE: certainly only compatible with PHP 64bits More...
 

Detailed Description

Log message formatter that uses the apache Avro format.

Since
1.26
Author
Erik Bernhardson ebern.nosp@m.hard.nosp@m.son@w.nosp@m.ikim.nosp@m.edia..nosp@m.org
Note
© 2015 Erik Bernhardson and Wikimedia Foundation.

Definition at line 38 of file AvroFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Logger\Monolog\AvroFormatter::__construct ( array  $schemas)
Parameters
array$schemasMap from Monolog channel to Avro schema. Each schema can be either the JSON string or decoded into PHP arrays.

Definition at line 68 of file AvroFormatter.php.

References MediaWiki\Logger\Monolog\AvroFormatter\$schemas, and writer.

Member Function Documentation

◆ encodeLong()

MediaWiki\Logger\Monolog\AvroFormatter::encodeLong (   $id)
private

convert an integer to a 64bits big endian long (Java compatible) NOTE: certainly only compatible with PHP 64bits

Parameters
int$id
Returns
string the binary representation of $id

Definition at line 166 of file AvroFormatter.php.

Referenced by MediaWiki\Logger\Monolog\AvroFormatter\format().

◆ format()

MediaWiki\Logger\Monolog\AvroFormatter::format ( array  $record)

Formats the record context into a binary string per the schema configured for the records channel.

Parameters
array$record
Returns
string|null The serialized record, or null if the record is not valid for the selected schema.

Definition at line 83 of file AvroFormatter.php.

References $e, MediaWiki\Logger\Monolog\AvroFormatter\encodeLong(), AvroValidator\getErrors(), MediaWiki\Logger\Monolog\AvroFormatter\getSchema(), MediaWiki\Logger\Monolog\AvroFormatter\getSchemaRevisionId(), null, and writer.

Referenced by MediaWiki\Logger\Monolog\AvroFormatter\formatBatch().

◆ formatBatch()

MediaWiki\Logger\Monolog\AvroFormatter::formatBatch ( array  $records)

Format a set of records into a list of binary strings conforming to the configured schema.

Parameters
array$records
Returns
string[]

Definition at line 109 of file AvroFormatter.php.

References as, MediaWiki\Logger\Monolog\AvroFormatter\format(), and null.

◆ getSchema()

MediaWiki\Logger\Monolog\AvroFormatter::getSchema (   $channel)
protected

Get the writer for the named channel.

Parameters
string$channelName of the schema to fetch
Returns
\AvroSchema|null

Definition at line 126 of file AvroFormatter.php.

References null.

Referenced by MediaWiki\Logger\Monolog\AvroFormatter\format().

◆ getSchemaRevisionId()

MediaWiki\Logger\Monolog\AvroFormatter::getSchemaRevisionId (   $channel)

Get the writer for the named channel.

Parameters
string$channelName of the schema
Returns
int|null

Definition at line 153 of file AvroFormatter.php.

References null.

Referenced by MediaWiki\Logger\Monolog\AvroFormatter\format().

Member Data Documentation

◆ $encoder

AvroIOBinaryEncoder MediaWiki\Logger\Monolog\AvroFormatter::$encoder
protected

Definition at line 56 of file AvroFormatter.php.

◆ $io

AvroStringIO MediaWiki\Logger\Monolog\AvroFormatter::$io
protected

Definition at line 51 of file AvroFormatter.php.

◆ $schemas

array MediaWiki\Logger\Monolog\AvroFormatter::$schemas
protected
Initial value:
=
const MAGIC 0x0

Map from schema name to schema definition.

Definition at line 39 of file AvroFormatter.php.

Referenced by MediaWiki\Logger\Monolog\AvroFormatter\__construct().

◆ $writer

AvroIODatumWriter MediaWiki\Logger\Monolog\AvroFormatter::$writer
protected

Definition at line 61 of file AvroFormatter.php.


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