Traceback Grep
A module & command-line tool for extracting Python tracebacks from text.
Extracting tracebacks from bunch of files
$ tbgrep file1 file2 file3
Grepping for tracebacks in a pipeline
$ tail -f logfile | tbgrep
Displaying all unique tracebacks ordered by the number of occurrences
$ tbgrep --stats logfile
[...]
== 99 occurences ==================================================
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/bodhi/admin.py", line 209, in _masher_request
req_params=kwargs)
File "/usr/lib/python2.4/site-packages/fedora/client/proxyclient.py", line 285, in send_request
raise AuthError(_('Unable to log into server. Invalid'
AuthError: Unable to log into server. Invalid authentication tokens. Send new username and password
==================================================================
733 unique tracebacks extracted
Using the Python API
Once instantiated, you pass each line to the process method, which will return either None, or a string of a traceback.
from tbgrep import TracebackGrep
extractor = TracebackGrep()
for line in file('logfile'):
tb = extractor.process(line)
if tb:
print(tb)
Instead of displaying each traceback found in the file, tbgrep also supports generating statistics about all tracebacks in the file.
extractor = TracebackGrep(stats=True)
for line in file('logfile'):
extractor.process(line)
extractor.print_stats()
There are also some functions that allow you to search for tracebacks in a more convenient way.
from tbgrep import (
tracebacks_from_lines, tracebacks_from_file,
last_traceback_from_file)
for tb in tracebacks_from_file(file('logfile')):
print(tb)
for tb in tracebacks_from_file(file('logfile'), reverse=True):
print(tb)
print(last_traceback_from_file(file('logfile')))
Supported Input Formats
tbgrep can extract tracebacks from logs of various formats. For example, CherryPy starts the traceback on a line with other details (like module, timestamp, etc), but the rest of the trace starts at the beginning of the line. Apache logs, on the other hand, will prefix each line of the traceback with this information. tbgrep is designed to handle these kinds of situations
Metadata
Release files for tbgrep 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tbgrep-0.3.0.tar.gz | 18.1 kB | Without provenance | Details for tbgrep-0.3.0.tar.gz |
Release files / tbgrep-0.3.0.tar.gz
| Download URL | tbgrep-0.3.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53f0ec46ee24ce24cf2a178ac33de69e579e36d8a474c55fd564614146b5810d
|
|
BLAKE2b-256 checksum How to use checksums |
4f0dd411b33432dbeb419d743e28c33094516d2261ba0dca20dd9ad170ba62b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tbgrep 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.