Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Console\Commands;
- use Symfony\Component\Process\Process;
- use Symfony\Component\Process\Exception\ProcessFailedException;
- use Illuminate\Console\Command;
- class LogClearCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'log:clear';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Clear the log file';
- /**
- * Processs shell
- * @var Symfony\Component\Process\Process
- */
- protected $process;
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- $this->process = new Process('truncate -s 0 storage/logs/laravel.log');
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $this->process->run();
- if (!$this->process->isSuccessful()) {
- throw new ProcessFailedException($this->process);
- }
- $this->info('Log file cleared!');
- }
- }
Add Comment
Please, Sign In to add comment