sroze/log-stream

There is no license information available for the latest version (0.4.5) of this package.

0.4.5 2017-08-27 13:35 UTC

This package is auto-updated.

Last update: 2021-01-31 00:33:35 UTC


README

This is a PHP library that is a client for LogStream.

Getting started

This library can be used both as standalone or with the Symfony integration.

Standalone

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
    )
);

Symfony integration

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

Configuration reference

log_stream:
    # Address of LogStream API
    url: https://api.logstream.io

Operation runner

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);