定制 gamma/api-logger-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gamma/api-logger-bundle

Composer 安装命令:

composer require gamma/api-logger-bundle

包简介

provides tools for REST API requests logging and profoiling

README 文档

README

Build Status

##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.

##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:

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

// parameters.yml
   gamma_logger_enabled: true
   gamma_logger_slow_time_limit: 1000

or add to config.yml

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

logging

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

Logging to separate log file

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

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

统计信息

  • 总下载量: 46.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固