Skip to content

Commit

Permalink
Changed the log level on exceptions in BlockRenderer from critical to…
Browse files Browse the repository at this point in the history
… error (#285)

As critical, log entries may trigger further actions, i.e. sending mails from monolog and similar. This makes even more sense as the default settings in the block bundle simply catch the exception.
  • Loading branch information
uwej711 authored and soullivaneuh committed May 28, 2016
1 parent 0e27ee6 commit 98151c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Block/BlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public function render(BlockContextInterface $blockContext, Response $response =
$response = $this->addMetaInformation($response, $blockContext, $service);
} catch (\Exception $exception) {
if ($this->logger) {
$this->logger->critical(sprintf('[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId(), $exception->getMessage()));
$this->logger->error(sprintf(
'[cms::renderBlock] block.id=%d - error while rendering block - %s',
$block->getId(),
$exception->getMessage()
), compact('exception'));
}

// reseting the state object
Expand Down
4 changes: 2 additions & 2 deletions Tests/Block/BlockRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testRenderWithWrongResponse()
}));

// mock the logger to ensure a crit message is logged
$this->logger->expects($this->once())->method('critical');
$this->logger->expects($this->once())->method('error');

// mock a block object
$block = $this->getMock('Sonata\BlockBundle\Model\BlockInterface');
Expand Down Expand Up @@ -145,7 +145,7 @@ public function testRenderBlockWithException()
->will($this->returnValue($response));

// mock the logger to ensure a crit message is logged
$this->logger->expects($this->once())->method('critical');
$this->logger->expects($this->once())->method('error');

// mock a block object
$block = $this->getMock('Sonata\BlockBundle\Model\BlockInterface');
Expand Down

0 comments on commit 98151c5

Please sign in to comment.