Skip to content

Commit

Permalink
Logger: Fix Throwable condition for php5
Browse files Browse the repository at this point in the history
  • Loading branch information
josefbenjac committed Aug 17, 2017
1 parent 402f863 commit a62bfd4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/ExceptionFileLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function log($message, $priority)
throw new InvalidStateException('Directory "' . $this->directory . '" is not found or is not directory.');
}

$exceptionFile = $message instanceof Throwable ? $this->getExceptionFile($message) : NULL;
$exceptionFile = ($message instanceof Exception || $message instanceof Throwable) ? $this->getExceptionFile($message) : NULL;
$line = Utils::formatLogLine($message, $exceptionFile);
$file = $this->directory . '/' . strtolower($priority) . '.log';

Expand Down
7 changes: 3 additions & 4 deletions src/SendMailLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Contributte\Logging;

use Contributte\Logging\Mailer\IMailer;
use Exception;
use Throwable;

class SendMailLogger extends AbstractLogger
Expand Down Expand Up @@ -49,10 +50,8 @@ public function setMailer($mailer)
*/
public function log($message, $priority)
{
if (!in_array($priority, [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL], TRUE))
return;
if (!($message instanceof Throwable))
return;
if (!in_array($priority, [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL], TRUE)) return;
if (!($message instanceof Exception) || !($message instanceof Throwable)) return;

$snooze = is_numeric($this->emailSnooze)
? $this->emailSnooze
Expand Down
6 changes: 2 additions & 4 deletions src/Sentry/SentryLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public function __construct(array $config)
*/
public function log($message, $priority)
{
if (!in_array($priority, [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL], TRUE))
return;
if (!($message instanceof Throwable))
return;
if (!in_array($priority, [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL], TRUE)) return;
if (!($message instanceof Exception) || !($message instanceof Throwable)) return;

// Send to Sentry
$this->makeRequest($message);
Expand Down

0 comments on commit a62bfd4

Please sign in to comment.