Bug report generation
=====================

    Automated environment collection for bug reports.


Enabling bug reporting
----------------------

Yuio can automatically generate an environment report that can help with
troubleshooting bugs. Set :attr:`App.bug_report <yuio.app.App.bug_report>`
to add :flag:`--bug-report` flag to your app:

.. code-block:: python

    import yuio.app

    @yuio.app.app(bug_report=True)
    def main():
        ...

When user submits a bug report, you can ask them to attach environment data
generated by Yuio. It includes system information, python version, versions
of installed application and its dependencies, and so on:

.. code-block:: console

    $ ./app --bug-report
    ```
                          System
                          ~~~~~~

                    date: 2026-01-01 00:00:00
                platform: linux (Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39)
                      os: Ubuntu 24.04
                  python: CPython 3.13.8
                 machine: x86_64 64bit


                          Versions
                          ~~~~~~~~

                     app: 1.0.0
                    yuio: 2.0.0


                          Terminal and CLI
                          ~~~~~~~~~~~~~~~~

     interactive support: FULL
         terminal colors: ANSI_TRUE
         detected colors: True
                    term: xterm-256color
               colorterm:
                   shell: /usr/bin/fish
                      ci: False
                     wsl: 2.6.1.0
    ```


Adding custom reporters
-----------------------

You can extend the default report by providing custom environment collectors
(see :class:`yuio.dbg.ReportSettings`):

.. code-block:: python

    import yuio.app
    import yuio.dbg

    def _collect_additional_data():
        return yuio.dbg.Report(
            title="Custom report data",
            items=[
                ...
            ]
        )

    @yuio.app.app(
        bug_report=yuio.dbg.ReportSettings(
            collectors=[_collect_additional_data],
        )
    )
    def main():
        ...
