Giter Site home page Giter Site logo

think-trace's Introduction

think-trace

用于ThinkPHP6+的页面Trace扩展,支持Html页面和浏览器控制台两种方式输出。

安装

composer require topthink/think-trace

配置

安装后config目录下会自带trace.php配置文件。

type参数用于指定trace类型,支持html和console两种方式。

think-trace's People

Contributors

liu21st avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

think-trace's Issues

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

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

Console的output函数内number_format没有设置千分位分割导致除法报错

Html的写法是

        // 获取基本信息
        $runtime = number_format(microtime(true) - $app->getBeginTime(), 10, '.', '');
        $reqs    = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞';
        $mem     = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2);

在Console里面却是

        // 获取基本信息
        $runtime = number_format(microtime(true) - $app->getBeginTime(), 10);
        $reqs    = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞';
        $mem     = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2);

在Console里,当$runtime大于1000会出现千位分割,1/$runtime会出现“A non well formed numeric value encountered”错误

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.