innmind/stack-trace

检查异常堆栈跟踪的工具

4.1.0 2023-09-17 15:22 UTC

This package is auto-updated.

Last update: 2024-09-17 17:21:11 UTC


README

Build Status codecov Type Coverage

检查异常堆栈跟踪的工具

安装

composer require innmind/stack-trace

用法

use Innmind\StackTrace\{
    StackTrace,
    Render,
};
use Innmind\OperatingSystem\Factory;
use Innmind\Server\Control\Server\Command;

$trace = StackTrace::of(new AnyClassImplementingPhpThrowableInterface);

// every call frames that lead to the exception to be thrown
// (deepest call frame first)
$callFrames = $trace->throwable()->callFrames();

// this will render the stack trace via graphviz
Factory::build()
    ->control()
    ->processes()
    ->execute(
        Command::foreground('dot')
            ->withShortOption('Tsvg')
            ->withShortOption('o', 'graph.svg')
            ->withInput(
                Render::of()($trace)
            ),
    )
    ->wait();

注意:渲染的svg文件包含调用帧和异常发生的文件链接,你可以通过向Render对象提供一个Link实例来更改链接。Link的示例。

渲染的堆栈跟踪示例: