Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法在指定控制器中关闭trace #4

Open
happylhb opened this issue Feb 5, 2021 · 1 comment
Open

无法在指定控制器中关闭trace #4

happylhb opened this issue Feb 5, 2021 · 1 comment

Comments

@happylhb
Copy link

happylhb commented Feb 5, 2021

public function handle($request, Closure $next)
{
$debug = $this->app->isDebug();

    // 注册日志监听
    if ($debug) {
        $this->log = [];
        $this->app->event->listen(LogWrite::class, function ($event) {
            if (empty($this->config['channel']) || $this->config['channel'] == $event->channel) {
                $this->log = array_merge_recursive($this->log, $event->log);
            }
        });
    }

    $response = $next($request);

    // Trace调试注入
    if ($debug) {      //这里的判断,还是读取的最初的值,无法在其他中间件或控制器中,改变此属性
        $data = $response->getContent();
        $this->traceDebug($response, $data);
        $response->content($data);
    }

    return $response;
}
@liu21st
Copy link
Member

liu21st commented Feb 7, 2021

设计如此 在部署模式应当关闭trace或者使用socket方式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants