Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from LKDevelopment/feature/use-custom-logfiles
Browse files Browse the repository at this point in the history
Implement Custom Log File #2
  • Loading branch information
mattstauffer authored Oct 3, 2017
2 parents 3be9ce2 + f9c307e commit e522fe6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/DeleteOldSoftDeletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,23 @@ private function logAffectedRows(Collection $deletedRows)
if (! $this->config->get('quicksand.log', false) || empty($preparedRows)) {
return;
}

if (!! $this->config->get('quicksand.custom_log_file', false)) {
$logHandlers = Log::getMonolog()->getHandlers();
Log::getMonolog()->setHandlers([]);
Log::useFiles($this->config->get('quicksand.custom_log_file'));

}

Log::info(sprintf(
'%s force deleted these number of rows: %s',
get_class($this),
print_r($preparedRows, true)
));

if (!! $this->config->get('quicksand.custom_log_file', false)) {
Log::getMonolog()->setHandlers($logHandlers);
}
}

private function prepareForLogging($rawDeletedRows)
Expand Down
5 changes: 5 additions & 0 deletions src/config/quicksand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
// Whether to log the number of soft deleted records per model
'log' => false,

// If you log the soft deleted records per model, this is the path where it will be stored
// false if you want the default laravel log file
// Sample Path: __DIR__.'/path/to/storage/from/log.file
'custom_log_file' => false,

// List of models to run Quicksand on
'models' => [
// \App\Example::class,
Expand Down

0 comments on commit e522fe6

Please sign in to comment.