2017 © Pedro Peláez
 

library log-rabbitmq

image

xervice/log-rabbitmq

  • Monday, July 30, 2018
  • by mibexx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

LogRabbitMq

Build Status Scrutinizer Code Quality Code Coverage, (*1)

Installation

composer require xervice/log-rabbitmq

Configuration

To use rabbitmq as log provider, you have to define it in the LoggerDependencyProvider and RabbitMQDepoendencyProvider., (*2)

<?php

namespace App\Logger;

use Xervice\Logger\LoggerDependencyProvider as XerviceLoggerDependencyProvider;
use Xervice\LogRabbitMq\Business\Log\QueueLogHandler;

class LoggerDependencyProvider extends XerviceLoggerDependencyProvider
{
    /**
     * @return array
     */
    protected function getLogHandler(): array
    {
        return [
            new QueueLogHandler()
        ];
    }

}
<?php

namespace App\RabbitMQ;

use Xervice\LogRabbitMq\Business\Queue\LogExchange;
use Xervice\LogRabbitMq\Business\Queue\LogQueue;
use Xervice\RabbitMQ\RabbitMQDependencyProvider as XerviceRabbitMQDependencyProvider;
use XerviceTest\LogRabbitMq\Listener\LogListener;

class RabbitMQDependencyProvider extends XerviceRabbitMQDependencyProvider
{
    /**
     * @return array
     */
    protected function getQueues(): array
    {
        return [
            new LogQueue()
        ];
    }

    /**
     * @return array
     */
    protected function getExchanges(): array
    {
        return [
            new LogExchange()
        ];
    }

}

To add LogHandler as Worker you can extend from \Xervice\LogRabbitMq\Business\Queue\AbstractLogQueueListener., (*3)

Example, (*4)

<?php


namespace XerviceTest\LogRabbitMq\Listener;


use DataProvider\LogMessageDataProvider;
use Xervice\LogRabbitMq\Business\Queue\AbstractLogQueueListener;

class LogListener extends AbstractLogQueueListener
{
    /**
     * @param \DataProvider\LogMessageDataProvider $dataProvider
     */
    public function handleLog(LogMessageDataProvider $dataProvider)
    {
        echo $dataProvider->getTitle();
    }
}

Adding to RabbitMQDependencyProvider, (*5)

<?php

namespace App\RabbitMQ;

use Xervice\RabbitMQ\RabbitMQDependencyProvider as XerviceRabbitMQDependencyProvider;
use XerviceTest\LogRabbitMq\Listener\LogListener;

class RabbitMQDependencyProvider extends XerviceRabbitMQDependencyProvider
{
    /**
     * @return array
     */
    protected function getListener(): array
    {
        return [
            new LogListener()
        ];
    }
}

The Versions

30/07 2018
30/07 2018
28/07 2018