Skip to content

Commit

Permalink
add trigger_error when logger not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Andru Cherny committed Jun 4, 2021
1 parent 31e62aa commit 3b3bf46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion .docker/app_test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ COPY . /packages/ValueObject
WORKDIR /packages/ValueObject

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer -vvv global require hirak/prestissimo
RUN composer install
8 changes: 8 additions & 0 deletions src/Utils/LoggerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ public function setLogger(LoggerInterface $logger): self
* @param int $level
* @param mixed[] $context
*
* @SuppressWarnings(PHPMD.ErrorControlOperator)
*
* @return $this
*/
public function logMessage(string $message, int $level, array $context = []): self
{
if (!$this->logger instanceof LoggerInterface) {
@trigger_error('Logger not set for class:'.get_class($this), E_USER_WARNING);

return $this;
}

Expand Down Expand Up @@ -105,11 +109,15 @@ public function logMessage(string $message, int $level, array $context = []): se
* @param int $level
* @param string $message The error message to log
*
* @SuppressWarnings(PHPMD.ErrorControlOperator)
*
* @return $this
*/
public function logException(Throwable $exception, int $level, string $message): self
{
if (!$this->logger instanceof LoggerInterface) {
@trigger_error('Logger not set for class:'.get_class($this), E_USER_WARNING);

return $this;
}

Expand Down

0 comments on commit 3b3bf46

Please sign in to comment.