Giter VIP home page Giter VIP logo

api-logger-bundle's Introduction

API Logger Bundle

Version Build Status Coverage Status Scrutinizer Code Quality License

Versions

For buzz<0.16 please use nixilla/api-logger-bundle:^0.4 and for latest buzz:^1, use nixilla/api-logger-bundle:^0.5.1

Installation

Step 1: composer

composer require nixilla/api-logger-bundle

Step 2: enable bundle by adding it to AppKernel

<?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

For latest buzz all you need to do is add this line into config/packages/buzz.yml

services:
    Buzz\Browser:
        arguments: ['@Buzz\Client\BuzzClientInterface', '@Psr\Http\Message\RequestFactoryInterface']
        calls:
            # other middleware classes here
            - ['addMiddleware', ['@Nixilla\Api\LoggerBundle\Middleware\ApiLoggerMiddleware']]

For earlier version of buzz <0.16 and earlier version of this bundle <0.5 you need to configure like this:

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

# 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

# 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" ] ]

If you're using twilio/sdk you may want to override their Http Client in config_dev.yml

# app/config/config_dev.yml
imports:
    - { resource: config.yml }

services:
    
    twilio.http.client:
        class: Nixilla\Api\LoggerBundle\Proxy\Twilio\CurlClient
        calls:
            - [ "setLogger", [ "@nixilla.api.logger" ] ]
            
    twilio.rest.client:
        class: Twilio\Rest\Client
        arguments: [ "%twilio.username%", "%twilio.password%", ~, ~, '@twilio.http.client']

api-logger-bundle's People

Contributors

nixilla avatar sergiu-popa avatar slejnej avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

slejnej

api-logger-bundle's Issues

Buzz reported issue

Hi,

in order to get the data after logCall was made we are missing code to reset the pointer of contents, else in Symfony 4+ data is always empty. Reported in this issue

In ApiLoggerMiddleware.php on line 56 we could just do..
/** need to rewind the contents so it can be retrieved later!!! */ $response->getBody()->rewind();

PHP version conflict

Hi I'm getting this error when trying to install the api-logger-bundle:

Problem 1
- Installation request for nixilla/api-logger-bundle dev-master -> satisfiable by nixilla/api-logger-bundle[dev-master].
- nixilla/api-logger-bundle dev-master requires php >=5.4 -> your PHP version (5.5.9-1ubuntu4.14) does not satisfy that requirement.

My composer.json looks like:

"require-dev": {
        "sensio/generator-bundle": "~2.3",
        "symfony/phpunit-bridge": "~2.7",
        "nixilla/api-logger-bundle": "dev-master"
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.