Skip to content

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

@happylhb

Description

@happylhb

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions