-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
389 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor | ||
bin | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
filter: | ||
excluded_paths: | ||
- spec/* | ||
|
||
build: | ||
environment: | ||
variables: | ||
COMPOSER_MEMORY_LIMIT: -1 | ||
dependencies: | ||
before: | ||
- pecl install xdebug | ||
- echo "zend_extension=xdebug.so" > /home/scrutinizer/.phpenv/versions/7.2.0/etc/conf.d/xdebug.ini | ||
|
||
tests: | ||
override: | ||
- | ||
command: 'bin/phpspec run -f progress' | ||
coverage: | ||
file: 'build/logs/clover.xml' | ||
format: 'clover' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.2 | ||
|
||
env: | ||
global: | ||
- COMPOSER_MEMORY_LIMIT=-1 | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar update --prefer-dist | ||
- php composer.phar update --prefer-dist --ignore-platform-reqs | ||
|
||
script: bin/phpspec run -fpretty --verbose | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.composer/cache | ||
|
||
after_script: | ||
- php bin/php-coveralls -v |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# API Logger Bundle | ||
|
||
[](https://packagist.org/packages/nixilla/api-logger-bundle) | ||
[](https://travis-ci.org/nixilla/api-logger-bundle) | ||
[](https://coveralls.io/github/nixilla/api-logger-bundle?branch=develop) | ||
[](https://scrutinizer-ci.com/g/nixilla/api-logger-bundle/?branch=develop) | ||
[](https://packagist.org/packages/nixilla/api-logger-bundle) | ||
|
||
## Installation | ||
|
||
Step 1: composer | ||
|
||
```bash | ||
composer require nixilla/api-logger-bundle | ||
``` | ||
|
||
Step 2: enable bundle by adding it to AppKernel | ||
|
||
|
||
```php | ||
<?php | ||
|
||
// app/AppKernel.php | ||
|
||
if (in_array($this->getEnvironment(), array('dev', 'test'))) { | ||
// your other dev bundles here | ||
$bundles[] = new Nixilla\Api\LoggerBundle\NixillaApiLoggerBundle(); | ||
} | ||
|
||
``` | ||
|
||
Step 3: configuration | ||
|
||
If you're use HWIOAuthBundle and you want to monitor all OAuth API calls, you can now override default | ||
`hwi_oauth.http_client` service used by this bundle by adding this few lines to your `config_dev.yml` file | ||
|
||
```yaml | ||
# app/config/config_dev.yml | ||
imports: | ||
- { resource: config.yml } | ||
|
||
parameters: | ||
buzz.client.class: Nixilla\Api\LoggerBundle\Proxy\Buzz\Client\Curl | ||
|
||
services: | ||
hwi_oauth.http_client: | ||
class: "%buzz.client.class%" | ||
calls: | ||
- [ "setLogger", [ "@nixilla.api.logger" ] ] | ||
``` | ||
If you're using `sensio/buzz-bundle`, you may want to override the `buzz.client` in config_dev.yml | ||
|
||
```yaml | ||
# app/config/config_dev.yml | ||
imports: | ||
- { resource: config.yml } | ||
parameters: | ||
buzz.client.class: Nixilla\Api\LoggerBundle\Proxy\Buzz\Client\Curl | ||
services: | ||
buzz.client: | ||
class: "%buzz.client.class%" | ||
calls: | ||
- [ "setTimeout", [ "%buzz.client.timeout%" ] ] | ||
- [ "setLogger", [ "@nixilla.api.logger" ] ] | ||
``` | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
suites: | ||
default: | ||
namespace: Nixilla\Api\LoggerBundle | ||
psr4_prefix: Nixilla\Api\LoggerBundle | ||
|
||
extensions: | ||
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension: | ||
blacklist: [ 'spec', 'vendor' ] | ||
format: | ||
- clover | ||
- html | ||
|
||
output: | ||
clover: build/logs/clover.xml | ||
html: build/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace spec\Nixilla\Api\LoggerBundle\DataCollector; | ||
|
||
use Nixilla\Api\LoggerBundle\DataCollector\ApiDataCollector; | ||
use Nixilla\Api\LoggerBundle\Logger\Api; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\DataCollector\DataCollector; | ||
|
||
class ApiDataCollectorSpec extends ObjectBehavior | ||
{ | ||
function let(Api $logger) | ||
{ | ||
$this->beConstructedWith($logger); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(ApiDataCollector::class); | ||
$this->shouldHaveType(DataCollector::class); | ||
} | ||
|
||
function it_implements_getName() | ||
{ | ||
$this->getName()->shouldNotReturn(null); | ||
} | ||
|
||
function it_implements_collect_method(Api $logger, Request $request, Response $response) | ||
{ | ||
$logger->getCalls()->shouldBeCalled()->willReturn([['time' => 5 ]]); | ||
$logger->getCallsCount()->shouldBeCalled()->willReturn(5); | ||
|
||
$this->collect($request, $response); | ||
|
||
$this->getCalls()->shouldNotReturn(null); | ||
$this->getCallsCount()->shouldReturn(5); | ||
|
||
$this->getTime()->shouldReturn(5); | ||
|
||
$this->reset(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
spec/DependencyInjection/NixillaApiLoggerExtensionSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace spec\Nixilla\Api\LoggerBundle\DependencyInjection; | ||
|
||
use Nixilla\Api\LoggerBundle\DependencyInjection\NixillaApiLoggerExtension; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\Extension; | ||
|
||
class NixillaApiLoggerExtensionSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(NixillaApiLoggerExtension::class); | ||
$this->shouldHaveType(Extension::class); | ||
} | ||
|
||
function it_implements_required_load_method(ContainerBuilder $container) | ||
{ | ||
$container->fileExists(Argument::any())->willReturn(true); | ||
$container->setDefinition(Argument::any(), Argument::any())->shouldBeCalled(); | ||
$container->setParameter(Argument::any(), Argument::any())->shouldBeCalled(); | ||
|
||
$this->load([], $container); | ||
} | ||
} |
Oops, something went wrong.