Skip to content

Commit

Permalink
Introduce interface for command loggers
Browse files Browse the repository at this point in the history
This interface is necessary so the Symfony Bundle can allow registering multiple loggers for commands
  • Loading branch information
alcaeus committed Sep 13, 2019
1 parent d78a073 commit f7021a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/Doctrine/ODM/MongoDB/APM/CommandLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
use Countable;
use MongoDB\Driver\Monitoring\CommandFailedEvent;
use MongoDB\Driver\Monitoring\CommandStartedEvent;
use MongoDB\Driver\Monitoring\CommandSubscriber;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
use function count;
use function MongoDB\Driver\Monitoring\addSubscriber;
use function MongoDB\Driver\Monitoring\removeSubscriber;

final class CommandLogger implements Countable, CommandSubscriber
final class CommandLogger implements Countable, CommandLoggerInterface
{
/** @var Command[] */
private $commands = [];
Expand Down
20 changes: 20 additions & 0 deletions lib/Doctrine/ODM/MongoDB/APM/CommandLoggerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\APM;

use MongoDB\Driver\Monitoring\CommandSubscriber;

interface CommandLoggerInterface extends CommandSubscriber
{
/**
* Registers this command logger instance with the MongoDB library so it can receive command events
*/
public function register() : void;

/**
* Unregisters this command logger instance with the MongoDB library so it no longer receives command events
*/
public function unregister() : void;
}

0 comments on commit f7021a2

Please sign in to comment.