Skip to content

Commit

Permalink
avoid too many verbose logs on production. Lots of logs are not neces…
Browse files Browse the repository at this point in the history
… sary because there is

already throw Exception that can be catched by application
  • Loading branch information
jbrousseauDigitick committed Jun 6, 2018
1 parent 59fc7fc commit 735c07c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/Digitick/Foundation/Fuse/Command/Http/HttpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,22 +349,23 @@ private function exceptionFactory(TransferException $exc)
switch ($exc->getCode()) {

case NotFoundException::STATUS_CODE :
$this->warning("Throw exception of type NotFoundException");
$this->debug("Throw exception of type NotFoundException");
$thrownException = new NotFoundException ($exc->getMessage(), $exc->getCode(), $exc);
break;

case ForbiddenException::STATUS_CODE :
$this->warning("Throw exception of type ForbiddenException");
//avoid too many verbose logs on production
$this->debug("Throw exception of type ForbiddenException");
$thrownException = new ForbiddenException($exc->getMessage(), $exc->getCode(), $exc);
break;

case MethodNotAllowedException::STATUS_CODE :
$this->warning("Throw exception of type MethodNotAllowed");
$this->debug("Throw exception of type MethodNotAllowed");
$thrownException = new MethodNotAllowedException($exc->getMessage(), $exc->getCode(), $exc);
break;

case BadRequestException::STATUS_CODE :
$this->warning("Throw exception of type MethodNotAllowed");
$this->debug("Throw exception of type BadRequestException");
$thrownException = new BadRequestException($exc->getMessage(), $exc->getCode(), $exc);
break;

Expand All @@ -385,7 +386,7 @@ private function exceptionFactory(TransferException $exc)
break;

case TemporaryUnavailableException::STATUS_CODE :
$this->error("Throw exception of type NotImplementedException");
$this->error("Throw exception of type TemporaryUnavailableException");
$thrownException = new TemporaryUnavailableException($exc->getMessage(), $exc->getCode(), $exc);
break;

Expand Down
9 changes: 7 additions & 2 deletions src/Digitick/Foundation/Fuse/Command/Soap/SoapCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@ public function send()
$this->logSoapRequestAndResponse();
} catch (SoapFault $fault) {
$this->logSoapRequestAndResponse();
$this->error(sprintf("Transfer exception caught. Type : %s, status code = %s, message = %s",
$errorLog = sprintf("Transfer exception caught. Type : %s, status code = %s, message = %s",
get_class($fault),
$fault->getCode(),
$fault->getMessage()
)
);
if ($fault->getCode() < 500) {
//avoid too many verbose logs on production
$this->debug($errorLog);
} else {
$this->error($errorLog);
}
throw $fault;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function executeAsync(HttpCommandInterface $command)
}
} catch (LogicException $exc) {
$this->log(LogLevel::DEBUG, "Logic exception. Call onLogicError");
$this->log(LogLevel::INFO, "Success for command group " . $command->getKey());
$this->log(LogLevel::DEBUG, "Success for command group " . $command->getKey());
$this->circuitBreaker->reportSuccess($command->getKey());
return $command->onLogicError($exc);
} catch (ServiceException $exc) {
Expand Down

0 comments on commit 735c07c

Please sign in to comment.