Skip to main content

Turn Python stack traces into cleaner, more readable output

Project description

philiprehberger-stacktrace

Tests PyPI version License

Turn Python stack traces into cleaner, more readable output.

Installation

pip install philiprehberger-stacktrace

Usage

Global Install

from philiprehberger_stacktrace import install

install()  # replaces sys.excepthook

Manual Formatting

from philiprehberger_stacktrace import format_exception

try:
    risky_operation()
except Exception as e:
    report = format_exception(e)
    print(report.short())     # one-line summary
    print(report.detailed())  # colored with source context

Features

  • Colored output with syntax highlighting
  • Source context lines around the error
  • Hides stdlib/site-packages frames by default
  • Exception chain display (raise ... from ...)
  • One-line summary mode

API

  • install(color=True, context=2, hide_stdlib=True) — Replace sys.excepthook
  • format_exception(exc) — Returns ExceptionReport
  • report.short() — One-line summary
  • report.detailed(color, context, hide_stdlib) — Full formatted output

Development

pip install -e .
python -m pytest tests/ -v

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_stacktrace-0.1.4.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_stacktrace-0.1.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_stacktrace-0.1.4.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_stacktrace-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ed34805f9f02fe55eefeb434a7eb09253006f647ed779a0fb73054aaf5915fd3
MD5 f68bd5363fe678c5876a3f50fb81080c
BLAKE2b-256 0d13bfa55a62c94d011227fdc90d9edec509e296247eda470dbfbecaf602d0e6

See more details on using hashes here.

File details

Details for the file philiprehberger_stacktrace-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_stacktrace-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 60d29b6779cdc071d99fb9363de988a3fae03a51240c9a52ea30136534f62824
MD5 b0002d8ff2443bfd7fef9a5d0eb57d20
BLAKE2b-256 fecf6e0b21df1be04eb5802126f3d29b015cb3fa1005c7ef5fe2d69a7cd606bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page