Skip to content

Commit

Permalink
Improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Aug 8, 2019
1 parent 9bb2844 commit e77ee6f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

### [2.9.1](https://github.com/webeweb/core-bundle/tree/v2.9.1) (2019-08-08)

- Fix logs

### [2.9.0](https://github.com/webeweb/core-bundle/tree/v2.9.0) (2019-08-07)

- Add Logger interface into Abstract manager
Expand Down
2 changes: 1 addition & 1 deletion Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class AbstractController extends BaseController {
* @return BaseEvent|null Returns the event in case of success, null otherwise.
*/
protected function dispatchEvent($eventName, BaseEvent $event) {
$this->getLogger()->debug(sprintf("%s dispatch an event with name \"%s\"", get_class($this), $eventName));
$this->getLogger()->debug(sprintf('A controller dispatch an event with name "%s"', $eventName, ["_controller" => get_class($this), "_event" => get_class($event)]));
return EventDispatcherHelper::dispatch($this->getEventDispatcher(), $eventName, $event);
}

Expand Down
19 changes: 15 additions & 4 deletions Manager/AbstractManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ public function __construct(LoggerInterface $logger = null) {
* {@inheritDoc}
*/
public function addProvider(ProviderInterface $provider) {
if (null !== $this->getLogger()) {
$this->getLogger()->debug(sprintf("%s add a provider %s", get_class($this), get_class($provider)));
}
$this->providers[] = $provider;
return $this;
return $this->logInfo("A manager add a provider", ["_manager" => get_class($this), "_provider" => get_class($provider)]);
}

/**
Expand Down Expand Up @@ -90,6 +87,20 @@ public function indexOf(ProviderInterface $provider) {
return -1;
}

/**
* Log an info.
*
* @param string $message The message.
* @param array $context The context.
* @return AbstractManager Returns this manager.
*/
protected function logInfo($message, array $context) {
if (null !== $this->getLogger()) {
$this->getLogger()->info($message, $context);
}
return $this;
}

/**
* Set the providers.
*
Expand Down

0 comments on commit e77ee6f

Please sign in to comment.