Created
November 2, 2021 08:53
-
-
Save Warafux/44b656e6b3829f32960dca84a4860ab6 to your computer and use it in GitHub Desktop.
Revisions
-
Warafux created this gist
Nov 2, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ <?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Log; class CallCommandJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; protected $command = ""; protected $args = null; public function __construct($command, $args = []) { $this->command = $command; $this->args = $args; } public function handle() { Log::channel("jobs")->info("A job started: CallCommand ".$this->command); try{ Artisan::call($this->command, $this->args); }catch(\Exception $ex){ Log::channel("jobs")->error("A job failed: CallCommand ".$this->command. " EX:".$ex); } Log::channel("jobs")->info("A job finished: CallCommand ".$this->command); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; return [ // ... // ... // ... add 'jobs' to channels 'channels' => [ 'jobs' => [ 'driver' => 'single', 'path' => storage_path('logs/jobs.log'), 'level' => 'debug', ], ], // ... // ... // ... ]