Skip to content

Commit

Permalink
Merge pull request #10 from cgauge/console-logger
Browse files Browse the repository at this point in the history
Provide Console Socket
  • Loading branch information
deleugpn authored May 3, 2021
2 parents 969c3e9 + caaebfb commit 8be761d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Providers/ApmServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CustomerGauge\Logstash\Providers;

use CustomerGauge\Logstash\Sockets\ApmSocket;
use CustomerGauge\Logstash\Sockets\ConsoleApmSocket;
use CustomerGauge\Logstash\Sockets\HttpApmSocket;
use CustomerGauge\Logstash\Sockets\QueueApmSocket;
use Illuminate\Config\Repository;
Expand Down Expand Up @@ -44,6 +45,16 @@ public function register()

return new QueueApmSocket($socket);
});

$this->app->bind(ConsoleApmSocket::class, function () {
$config = $this->app->make(Repository::class);

$processor = $config->get('logging.processor.console');

$socket = $this->prepareSocketWithProcessors($processor);

return new ConsoleApmSocket($socket);
});
}

private function prepareSocketWithProcessors(?string $processor): ApmSocket
Expand Down
18 changes: 18 additions & 0 deletions src/Sockets/ConsoleApmSocket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace CustomerGauge\Logstash\Sockets;

final class ConsoleApmSocket
{
public ApmSocket $socket;

public function __construct(ApmSocket $socket)
{
$this->socket = $socket;
}

public function handle(array $record): bool
{
return $this->socket->handle($record);
}
}

0 comments on commit 8be761d

Please sign in to comment.