Provides logging and email notifications for Laravel console commands.
PHP >=5.4.0
Laravel >=5.2
-
Install package through
composer
:composer require illuminated/console-logger
-
Use
Illuminated\Console\Loggable
trait in your console command class:namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminated\Console\Loggable; class Foo extends Command { use Loggable; // ... }
-
Now your command is... To be continued...
Note, that Loggable
trait is overriding initialize
method:
trait Loggable
{
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->initializeLogging();
}
// ...
}
If your command is overriding initialize
method too, then you should call initializeLogging
method by yourself:
class Foo extends Command
{
use Loggable;
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->bar = $this->argument('bar');
$this->baz = $this->argument('baz');
$this->initializeLogging();
}
// ...
}