pinkfire/pinkfire-bundle

使用 Pinkfire 调试应用程序

安装量: 20,685

依赖者: 0

建议者: 0

安全性: 0

星星: 8

关注者: 4

分支: 1

开放问题: 1

类型:symfony-bundle

v2.1.0 2017-01-04 14:33 UTC

This package is auto-updated.

Last update: 2024-09-25 07:10:54 UTC


README

Pinkfire 是一个通过集中日志来帮助调试 SOA (面向服务的架构) 的优秀工具。

Pinkfire 是一个通过集中日志来帮助调试 SOA (面向服务的架构) 的优秀工具。

安装

将包添加到你的 composer.json

composer.phar require "pinkfire/pinkfire-bundle"

更新你的 app/AppKernel.php

<?php
    //...
    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        //...
        $bundles[] = new Pinkfire\PinkfireBundle\PinkfireBundle();
    }

更新你的配置文件 (app/config/config_dev.yml)

pinkfire:
    application : "my-application" # required
    host: "localhost"              # Optional
    port: 3000                     # Optional
    log_max_length: -1             # Optional, max length of read input data
    url_blacklist: [ ]             # Optional, array of URIs patterns to ignore
    url_debug: [ "_.*" ]           # Optional, array of URIs patterns to mark as debug
    log_level: warning             # Optional, log level used by the Monolog handler
    enabled: true                  # optional, allow to disable the request/response listener

关于 enabled: 如果该包能够连接到 pinkfire 服务器,则不会抛出异常或崩溃。但是,它会增加一点开销。因此,如果你的 pinkfire 服务器没有运行,而你又关心性能,你应该禁用它。

测试它

在浏览器中打开 pinkfire,然后访问你的网站(在开发环境中)。你应该看到所有主请求!

进一步了解

Monolog

你可以通过更新文件 app/config/config_dev.yml 中的 monolog 配置将日志转发到 pinkfire。

monolog:
    handlers:
        pinkfire:
            type: service
            id: pinkfire.monolog_handler

Guzzle

在 Guzzle 6(以及 csa/guzzle-bundle)中,会自动注册一个中间件,为每个请求添加 Pinkfire 头部(路径和通道)。

在旧版本的 Guzzle 中,使用我们的 Guzzle 订阅者

$client = new GuzzleHttp\Client();
$emitter = $client->getEmitter();
$emitter->attach($this->get('pinkfire.guzzle_subscriber'));

Buzz

提供了一个桥接器来与 Buzz 交互。

最简单的方法是将 pinkfire.buzz_listener 服务附加到 Buzz\Browser。如果你使用的是 Buzz\Client 而不是 Buzz\Browser,请使用 Pinkfire\PinkfireBundle\Buzz\Client\PinkfireClientDecorator

记录所有事情!

使用服务 pinkfire.request_aware.client 发送你想要的所有内容

// ...
$client = $this->get('pinkfire.request_aware.client');
$client->push('message', 'level', ['my_context' => 'context'], ['link_1' => 'https://github.com/pinkfire/PinkfireBundle']);
$client->patch('message', 'level', ['my_context' => 'context updated'], ['link_1' => 'https://github.com/pinkfire/PinkfireBundle']);

RequestAwareClient 将自动将推送/修补程序推送到主请求的路径和通道。