Cronos tasks logger sub-component

v1.0.4 2019-10-17 13:48 UTC

This package is auto-updated.

Last update: 2022-11-17 20:27:37 UTC


The following versions of PHP are supported.

  • PHP 7.1+


To install, use composer:

php composer.phar require pe/component-cronos-logger



namespace PE\Component\Cronos;

use Doctrine\DBAL\Connection;
use PE\Component\Cronos\Core\ServerInterface;
use PE\Component\Cronos\Logger\Handler\HandlerDBAL;
use PE\Component\Cronos\Logger\Handler\HandlerEcho;
use PE\Component\Cronos\Logger\Handler\HandlerPSR;
use PE\Component\Cronos\Logger\LoggerModule;
use Psr\Log\LoggerInterface;

// Initialize server somewhere and use some of options below (one or more)
/* @var $server ServerInterface */
$server = '...';

// A) Attach simple echo logger
$module = new LoggerModule(new HandlerEcho());
$server->attachModule('console-logger', $module);

// B) Attach PSR compatible logger
/* @var $logger LoggerInterface */
$logger = '...';
$module = new LoggerModule(new HandlerPSR($logger));
$server->attachModule('console-logger', $module);

// C) Attach database logger
/* @var $connection Connection */
$connection = '...';

$module = new LoggerModule(new HandlerDBAL($connection, 'log_task'));
$server->attachModule('db-logger', $module);