sroze / log-stream
Installs: 4 971
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- predis/predis: ~1.0
- symfony/serializer: ^2.8|^3.0
- tolerance/tolerance: ^0.4.0
Requires (Dev)
- behat/behat: ^3.0
- behat/symfony2-extension: ^2.1
- phpspec/phpspec: ~4.0
- symfony/config: ^2.8|~3.0
- symfony/dependency-injection: ^2.8|~3.0
- symfony/http-kernel: ^2.8|~3.0
Suggests
- sroze/tolerance: To handle fault tolerant LogStream
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);