Skip to content

Commit f67c438

Browse files
committed
Dispatch SaveNewLogEvent immediately skipping the job queue if the log event is an exception. Seems like jobs won't be submitted to queue if there is an exception triggered.
1 parent c725ae5 commit f67c438

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/LogToDB.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public function newFromMonolog(array $record)
214214
{
215215
if (!empty($this->connection)) {
216216
if ($this->saveWithQueue) {
217+
if (isset($record['context']['exception']) and !empty($record['context']['exception'])) {
218+
if (strpos(get_class($record['context']['exception']), "Exception") !== false) {
219+
dispatch_now(new SaveNewLogEvent($this, $record));
220+
}
221+
}
217222
if (empty($this->saveWithQueueName) and empty($this->saveWithQueueConnection)) {
218223
dispatch(new SaveNewLogEvent($this, $record));
219224
} else if (!empty($this->saveWithQueueName) and !empty($this->saveWithQueueConnection)) {
@@ -227,7 +232,7 @@ public function newFromMonolog(array $record)
227232
dispatch(new SaveNewLogEvent($this, $record))
228233
->onQueue($this->saveWithQueueName);
229234
}
230-
} else {
235+
} else {
231236
$log = CreateLogFromRecord::generate(
232237
$this->connection,
233238
$this->collection,

src/Models/LogToDbCreateObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function setContextAttribute(array $value)
5252
if (isset($value['exception'])) {
5353
if (!empty($value['exception'])) {
5454
$exception = $value['exception'];
55-
if (strpos(get_class($exception), "\Exception") !== false) {
55+
if (strpos(get_class($exception), "Exception") !== false) {
5656
$newexception = [];
5757
$newexception['class'] = get_class($exception);
5858
if (method_exists($exception, 'getMessage')) {

0 commit comments

Comments
 (0)