2017 © Pedro Peláez
 

symfony-bundle api-logger-bundle

provides tools for REST API requests logging and profoiling

image

gamma/api-logger-bundle

provides tools for REST API requests logging and profoiling

  • Sunday, July 15, 2018
  • by EvgeniyKuzmin
  • Repository
  • 2 Watchers
  • 1 Stars
  • 15,442 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

Smart Gamma API Logger Bundle

Build Status, (*1)

About

SmartGamma Symfony2 REST API Logger bundle is a tool that we use to create SmartGamma Symfony2 REST APIs.It enables detailed logging (possible to separate log) for incomming calls for APIs and tracks the duration, requests and responses body. As additional feature, it allows to profile your APIs and tracks slow API calls., (*2)

Installation

  1. Using Composer
composer require gamma/api-logger-bundle

Now, Composer will automatically download all required files, and install them for you. All that is left to do is to update your AppKernel.php file, and register the new bundle:, (*3)

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Gamma\ApiLoggerBundle\GammaApiLoggerBundle(),
    // ...
);

Configuration

By default the bundle is enabled and slow API call limit is 1000ms. To chage these settings either add to your parameters.yml, (*4)

// parameters.yml
   gamma_logger_enabled: true
   gamma_logger_slow_time_limit: 1000

or add to config.yml, (*5)

// config_dev.yml
parameters:
   gamma_logger_enabled: true
   gamma_logger_slow_time_limit: 500
// config_prod.yml
parameters:
   gamma_logger_enabled: false

Usage

Once the bundle was enabled, it will start to make logging all requests that have prefix "/api/" in URI to the log as shown on the sample, (*6)

!logging, (*7)

All API calls will be logged with "info" level. API calls that will take more then "gamma_logger_slow_time_limit" value will be logged with "error" level, (*8)

Logging to separate log file

In order to have API calls logged in separate files, you can use follow monolog configuration:, (*9)

// config.yml
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
            channels:     ["!api", "!api_slow"]
        api:
            type: stream
            path: %kernel.logs_dir%/%kernel.environment%.api.watch.log
            #level: info
            channels: ["api"]
        api_slow:
            type: stream
            path: %kernel.logs_dir%/%kernel.environment%.api.slow.log
            level: info
            channels: ["api_slow"]

TODO

  1. make hardcoded prefix "/api/" configurable

The Versions

15/07 2018

dev-master

9999999-dev

provides tools for REST API requests logging and profoiling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugen Kuzmin
by Eugeniy Kuzmin

api rest logging symfony2

15/07 2018

1.0.4

1.0.4.0

provides tools for REST API requests logging and profoiling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugeniy Kuzmin

api rest logging symfony2

15/07 2018

1.0.3

1.0.3.0

provides tools for REST API requests logging and profoiling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugeniy Kuzmin

api rest logging symfony2

30/12 2016

dev-sf3-fix

dev-sf3-fix

provides tools for REST API requests logging and profoiling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugen Kuzmin

api rest logging symfony2

10/07 2016

1.0.0

1.0.0.0

provides tools for REST API requests logging and profoiling

  Sources   Download

MIT

The Requires

 

The Development Requires

by Eugen Kuzmin

api rest logging symfony2