IcansLoggingComponent
A PHP Component providing:
- a Flume-Handler to write to a flume-node
- a FilterInterface to write filters which can be added to the handler and filter the data
- a PostProcessorInterface to write a postprocessor which can enrich the logged data
- a Timer to measure execution times
- a ProgressInformationInterface with default implementation to have progress messages in a CLI Command, (*1)
Installation:
You can use composer to install the component from packagist:
icans/logging-component, (*2)
Usages:, (*3)
ThriftFlumeHandler:, (*4)
<?php
$host = localhost
$port = 9129
$thriftSocket = new Thrift\Transport\TSocket($host, $port);
$thriftTransport = new Thrift\Transport\TBufferedTransport($thriftSocket);
$thriftProtocol = new Thrift\Protocol\TBinaryProtocolAccelerated($thriftTransport);
$thriftFlumeClient = new ICANS\Component\IcansLoggingComponent\Flume\ThriftFlumeEventServerClient($thriftProtocol), (*5)
$thriftFlumeProcessingHandler = new ThriftFlumeProcessingHandler($thriftTransport, $thriftFlumeClient);, (*6)
$formatter = new Monolog\Formatter\JsonFormatter();
$thriftFlumeProcessingHandler->setFormatter($formatter);, (*7)
//the processor has to implement the ICANS\Component\IcansLoggingComponent\Api\V1\PostProcessorInterface
$processor = new myPostProcessor();
$thriftFlumeProcessingHandler->pushProcessor($processor);, (*8)
$emptyFilter = new ICANS\Component\IcansLoggingComponent\Filter\EmptyFilter();
$thriftFlumeProcessingHandler->addFilter($emptyFilter);, (*9)
$recordData = array('testdata' => 'test');, (*10)
//will write to the flume node
$thriftFlumeProcessingHandler->write($recordData);, (*11)
RabbitMqHandler:, (*12)
<?php, (*13)