2021-05-20 23:54:07 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Listeners;
|
|
|
|
|
|
|
|
use Illuminate\Log\Events\MessageLogged;
|
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show logs in the console
|
|
|
|
*
|
|
|
|
* https://stackoverflow.com/questions/48264479/log-laravel-with-artisan-output
|
|
|
|
*/
|
|
|
|
class MessageLoggedListener
|
|
|
|
{
|
|
|
|
public function handle(MessageLogged $event)
|
|
|
|
{
|
2021-05-21 22:02:07 +08:00
|
|
|
if (app()->runningInConsole() && app()->environment() !== 'testing') {
|
2021-05-20 23:54:07 +08:00
|
|
|
$output = new ConsoleOutput();
|
|
|
|
$output->writeln("<$event->level>$event->message</$event->level>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|