Skip to content

Instantly share code, notes, and snippets.

@abrudtkuhl
Created January 11, 2023 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abrudtkuhl/1727f08bf688c28f3f2335e0b3e05fda to your computer and use it in GitHub Desktop.
Save abrudtkuhl/1727f08bf688c28f3f2335e0b3e05fda to your computer and use it in GitHub Desktop.
Logspot Log Driver For Laravel
<?php
namespace App\Logging;
use Illuminate\Log\Events\MessageLogged;
use Monolog\Logger;
use Logspot\Client;
class LogspotDriver
{
/**
* The Logspot client instance.
*
* @var \Logspot\Client
*/
protected $client;
/**
* Create a new Logspot driver instance.
*
* @param \Logspot\Client $client
* @return void
*/
public function __construct(Client $client)
{
$this->client = $client;
}
/**
* Log an event to Logspot.
*
* @param array $event
* @return void
*/
public function log(array $event)
{
$this->client->log($event['level'], $event['message'], $event['context']);
}
/**
* Register the listener for the MessageLogged event.
*
* @param \Illuminate\Log\Events\MessageLogged $event
* @return void
*/
public function listen(MessageLogged $event)
{
$this->log($event->record);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment