So I managed to solve this, mostly using the tap, config:
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'tap' => [\App\Logging\LogInjector::class]
],
And accompanied class:
use Illuminate\Support\Facades\Auth;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\WebProcessor;
class LogInjector
{
/**
* Customize the given logger instance.
*
* @param \Illuminate\Log\Logger $logger
* @return void
*/
public function __invoke($logger)
{
if (php_sapi_name() !== 'cli') {
$logger->pushProcessor(new WebProcessor());
}
$logger->pushProcessor(new IntrospectionProcessor(Logger::DEBUG, ['Illuminate\']));
dd(Auth::user());
}
}
I'm still struggling with getting the SID though. I tried the Auth::user() but that just returns my user model, which does not hold the SID, as this is in the token. I can't seem to access the Request object, which would've been a way to retrieve it.
Would be nice to somehow get access to the Request, as I'm thinking about logging some of the headers as well.