brille24/markdown-formatter

Formatting a stacktrace with markdown for monolog

1.0.9 2022-10-13 19:33 UTC

This package is auto-updated.

Last update: 2024-04-13 22:48:08 UTC


README

A formatter that prints the stack trace in markdown like so:

❗ Exception occurred here:

Function Location
MarkdownFormatterTest->testStackstrace() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestCase.php:1545
PHPUnit\Framework\TestCase->runTest() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestCase.php:1151
PHPUnit\Framework\TestCase->runBare() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestResult.php:726
PHPUnit\Framework\TestResult->run() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestCase.php:903
PHPUnit\Framework\TestCase->run() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestSuite.php:677
PHPUnit\Framework\TestSuite->run() markdown-formatter/vendor/phpunit/phpunit/src/Framework/TestSuite.php:677
PHPUnit\Framework\TestSuite->run() markdown-formatter/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:663
PHPUnit\TextUI\TestRunner->run() markdown-formatter/vendor/phpunit/phpunit/src/TextUI/Command.php:143
PHPUnit\TextUI\Command->run() markdown-formatter/vendor/phpunit/phpunit/src/TextUI/Command.php:96
PHPUnit\TextUI\Command::main() markdown-formatter/vendor/phpunit/phpunit/phpunit:98

Context:

{
    "failed_test": "some tests failed."
}

Usage

composer require brille24/markdown-formatter

Define the class Brille24\MarkdownFormatter\MarkdownFormatter as a service and use it (assuming that auto-wiring is on):

monolog:
    type: 'service'
    id: "Brille24\\MarkdownFormatter\\MarkdownFormatter"

If you want to customize the base path that the location is relative to you can pass the first argument to the root of the project eg.

service:
    Brille24\MarkdownFormatter\MarkdownFormatter:
        arguments:
            - '/some/path/to/the/project'