diff --git a/app/Console/Commands/SendDigest.php b/app/Console/Commands/SendDigest.php index fc9040c..a6bb509 100644 --- a/app/Console/Commands/SendDigest.php +++ b/app/Console/Commands/SendDigest.php @@ -2,8 +2,9 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; use App\Mail\Digest; +use Illuminate\Console\Command; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; class SendDigest extends Command @@ -33,23 +34,25 @@ class SendDigest extends Command $this->error('No schedule specified.'); return; } - // These are seperated because I may want to send multiple types // of digest in a single commend. if ($this->option('daily')) { foreach (config('app.daily_digest_recipients') as $recipient) { + Log::debug("Daily digest email sent to '{$recipient}'."); Mail::to($recipient)->send(new Digest('daily', config('app.current_trip_id'))); } } if ($this->option('weekly')) { foreach (config('app.weekly_digest_recipients') as $recipient) { + Log::debug("Weekly digest email sent to '{$recipient}'."); Mail::to($recipient)->send(new Digest('weekly', config('app.current_trip_id'))); } } if ($this->option('monthly')) { foreach (config('app.monthly_digest_recipients') as $recipient) { + Log::debug("Monthly digest email sent to '{$recipient}'."); Mail::to($recipient)->send(new Digest('monthly', config('app.current_trip_id'))); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e5372cb..a751882 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,6 +4,7 @@ namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use Illuminate\Support\Facades\Log; class Kernel extends ConsoleKernel { @@ -15,9 +16,23 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('digest:send --daily')->daily(); - $schedule->command('digest:send --weekly')->weekly(); - $schedule->command('digest:send --monthly')->monthly(); + $schedule->command('digest:send --daily') + ->daily() + ->onFailure(function() { + Log::error("Daily email digest send failed"); + }); + + $schedule->command('digest:send --weekly') + ->weekly() + ->onFailure(function() { + Log::error("Weekly email digest send failed"); + }); + + $schedule->command('digest:send --monthly') + ->monthly() + ->onFailure(function() { + Log::error("Monthly email digest send failed"); + }); } /**