Skip to content

Commit

Permalink
feature: artifact support
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Oct 23, 2018
1 parent d128e59 commit 06f9ebb
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
48 changes: 48 additions & 0 deletions src/ProcessManagerBundle/Monolog/ProcessLogEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Process Manager.
*
* LICENSE
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2017 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://github.com/dpfaffenbauer/ProcessManager/blob/master/gpl-3.0.txt GNU General Public License version 3 (GPLv3)
*/

namespace ProcessManagerBundle\Monolog;

use Symfony\Component\EventDispatcher\Event;

/**
* Class ProcessLogEvent.
*/
class ProcessLogEvent extends Event
{
const PROCESS_LOG_EVENT = 'process_manager.process.log_event';

/**
* @var array
*/
private $record;

public function __construct(array $record)
{
$this->record = $record;
}

/**
* @return array
*/
public function getRecord(): array
{
return $this->record;
}

public function setRecord(array $record): void
{
$this->record = $record;
}
}
14 changes: 12 additions & 2 deletions src/ProcessManagerBundle/Monolog/ProcessProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Monolog\Logger;
use ProcessManagerBundle\Logger\HandlerFactoryInterface;
use ProcessManagerBundle\Model\ProcessInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class ProcessProcessor
{
Expand All @@ -36,14 +37,20 @@ class ProcessProcessor
*/
private $registry;

/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;

/**
* @param HandlerFactoryInterface $defaultHandlerFactory
* @param ServiceRegistryInterface $registry
*/
public function __construct(HandlerFactoryInterface $defaultHandlerFactory, ServiceRegistryInterface $registry)
public function __construct(HandlerFactoryInterface $defaultHandlerFactory, ServiceRegistryInterface $registry, EventDispatcherInterface $eventDispatcher)
{
$this->defaultHandlerFactory = $defaultHandlerFactory;
$this->registry = $registry;
$this->eventDispatcher = $eventDispatcher;
}

public function __invoke(array $record): array
Expand Down Expand Up @@ -83,8 +90,11 @@ public function __invoke(array $record): array

unset($record['context']['process']);

$event = new ProcessLogEvent($record);
$this->eventDispatcher->dispatch(ProcessLogEvent::PROCESS_LOG_EVENT, $event);

$log->addRecord($record['level'], $record['message'], $record['context']);

return $record;
}
}
}
3 changes: 2 additions & 1 deletion src/ProcessManagerBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ services:
arguments:
- '@process_manager.default_handler_factory'
- '@process_manager.registry.process_handler_factories'
- '@event_dispatcher'
tags:
- { name: monolog.processor }

Expand All @@ -69,4 +70,4 @@ services:
- '%kernel.logs_dir%'

process_manager.default_report:
class: ProcessManagerBundle\Report\DefaultReport
class: ProcessManagerBundle\Report\DefaultReport

0 comments on commit 06f9ebb

Please sign in to comment.