diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index c63659858..95ab2a971 100755 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -712,7 +712,9 @@ class Binaries 'warning' ); - Log::warning($notInsertedCount.' articles failed to insert!'); + if (config('app.debug' === true)) { + Log::warning($notInsertedCount.' articles failed to insert!'); + } } unset($this->headersNotInserted); @@ -838,7 +840,9 @@ class Binaries $collectionID = $this->_pdo->lastInsertId(); DB::commit(); } catch (\Throwable $e) { - Log::error($e->getMessage()); + if (config('app.debug' === true)) { + Log::error($e->getMessage()); + } DB::rollBack(); } @@ -868,7 +872,9 @@ class Binaries $binaryID = $this->_pdo->lastInsertId(); DB::commit(); } catch (\Throwable $e) { - Log::error($e->getMessage()); + if (config('app.debug' === true)) { + Log::error($e->getMessage()); + } DB::rollBack(); } @@ -1606,13 +1612,19 @@ class Binaries try { return DB::insert($query); } catch (QueryException $e) { - Log::error($e->getMessage()); + if (config('app.debug' === true)) { + Log::error($e->getMessage()); + } $this->colorCli->debug('Query error occurred.'); } catch (\PDOException $e) { - Log::error($e->getMessage()); + if (config('app.debug' === true)) { + Log::error($e->getMessage()); + } $this->colorCli->debug('Query error occurred.'); } catch (\Throwable $e) { - Log::error($e->getMessage()); + if (config('app.debug' === true)) { + Log::error($e->getMessage()); + } $this->colorCli->debug('Query error occurred.'); } diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index 099bc5472..1238ac3b8 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -666,7 +666,9 @@ class Forking extends \fork_daemon $this->work[] = ['id' => $group->id]; } } catch (\PDOException $e) { - Log::debug($e->getMessage()); + if (config('app.debug' === true)) { + Log::debug($e->getMessage()); + } } } diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index fdf69c10a..df3ea1311 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -1643,7 +1643,9 @@ class ProcessAdditional return $files; } catch (\Throwable $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } $this->_debug('ERROR: Could not open temp dir: '.$e->getMessage()); return false; @@ -1780,7 +1782,9 @@ class ProcessAdditional $audioSample->clip(TimeCode::fromSeconds(30), TimeCode::fromSeconds(30)); $audioSample->save($format, $this->tmpPath.$audioFileName); } catch (\InvalidArgumentException $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } //We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file) } } @@ -1897,13 +1901,19 @@ class ProcessAdditional try { $this->ffmpeg->open($fileLocation)->frame(TimeCode::fromString($time === '' ? '00:00:03:00' : $time))->save($fileName); } catch (\RuntimeException $runtimeException) { - Log::error($runtimeException->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($runtimeException->getTraceAsString()); + } //We show no error we just log it, we failed to save the frame and move on } catch (\InvalidArgumentException $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } //We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file) } catch (\Throwable $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } //Again we do nothing, we just want to catch the error } } @@ -1995,7 +2005,9 @@ class ProcessAdditional $videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT); $videoSample->save($format, $fileName); } catch (\InvalidArgumentException $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } //We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file) } } @@ -2013,7 +2025,9 @@ class ProcessAdditional $videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT); $videoSample->save($format, $fileName); } catch (\InvalidArgumentException $e) { - Log::error($e->getTraceAsString()); + if (config('app.debug' === true)) { + Log::error($e->getTraceAsString()); + } //We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file) } } diff --git a/Changelog b/Changelog index c9c718e97..84578b7ae 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-01-30 DariusIII + * Chg: Log errors only if debugging is enabled * Chg: Use transaction when updating expired collections on tmux start * Chg: Simplify expressions to reduce cognitive load in ProcessAdditional class * Chg: Update composer/composer (1.8.2 => 1.8.3)