This is a PHP library that is a client for LogStream.
This library can be used both as standalone or with the Symfony integration.
use GuzzleHttp\Client;
use LogStream\Client\Http\JsonSerializableNormalizer;
use LogStream\Client\HttpClient;
use LogStream\TreeLoggerFactory;
$loggerFactory = new TreeLoggerFactory(
new HttpClient(
new Client(),
new JsonSerializableNormalizer(),
$address
)
);
The library contains a Symfony bundle. In order to activate it, you simply have to add in in your AppKernel.php
file:
$bundles = [
// ...
new LogStream\LogStreamBundle(),
];
Then, simply adds the configuration:
log_stream:
url: https://api.logstream.io
log_stream:
# Address of LogStream API
url: https://api.logstream.io
An interesting feature is the integration with the FaultTolerance library:
there's a client decorator, OperationRunnerDecorator
that accepts an operation runner to run the client's calls. That
way you can easily have a retry feature in case of problems in the real-time stream:
use LogStream\Client\FaultTolerance\OperationRunnerDecorator;
use FaultTolerance\OperationRunner\SimpleOperationRunner;
use FaultTolerance\OperationRunner\RetryOperationRunner;
use FaultTolerance\Waiter\SleepWaiter;
use FaultTolerance\WaitStrategy\Exponential;
$runner = new RetryOperationRunner(
new SimpleOperationRunner(),
new Max(new Exponential(new SleepWaiter(), 0.1), 10)
);
$client = new OperationRunnerDecorator($client, $operationRunner);