Retrospect
Dynamic logging after the fact
Classic logging expects perfect foresight, but only hindsight is 20/20!
Usage
Install via pip, then enter in a shell:
def hello(a, b=2):
"""docstring"""
a = 1
c = b * 2
a = b = c = a * 2 + b * c
print('output: a={} b={} c={}'.format(a, b, c))
return a, b, c
import retrospect
retro = retrospect.FunctionRetrospector(hello)
Now you can start inspecting lines in real-time:
>>> retro.implement(lines=True)
>>> hello(10)
((3, SetLineno, 3), {'a': 10, 'b': 2})
((4, SetLineno, 4), {'a': 1, 'b': 2})
((5, SetLineno, 5), {'a': 1, 'b': 2, 'c': 4})
((6, SetLineno, 6), {'a': 10, 'b': 10, 'c': 10})
output: a=10 b=10 c=10
((7, SetLineno, 7), {'a': 10, 'b': 10, 'c': 10})
((7, RETURN_VALUE, None), {'a': 10, 'b': 10, 'c': 10})
Or a specific set of lines:
>>> retro.implement(lines=[4], boundaries=False)
>>> hello(20)
((4, SetLineno, 4), {'a': 1, 'b': 2})
output: a=10 b=10 c=10
Or only on symbol changes:
>>> retro.implement(symbols=True, boundaries='start')
>>> hello(30)
((3, SetLineno, 3), {'a': 30, 'b': 2})
((3, STORE_FAST, 'a'), {'a': 30, 'b': 2})
((3, STORE_FAST, 'a'), {'a': 1, 'b': 2})
((4, STORE_FAST, 'c'), {'a': 1, 'b': 2})
((4, STORE_FAST, 'c'), {'a': 1, 'b': 2, 'c': 4})
((5, STORE_FAST, 'a'), {'a': 1, 'b': 2, 'c': 4})
((5, STORE_FAST, 'a'), {'a': 10, 'b': 2, 'c': 4})
((5, STORE_FAST, 'b'), {'a': 10, 'b': 2, 'c': 4})
((5, STORE_FAST, 'b'), {'a': 10, 'b': 10, 'c': 4})
((5, STORE_FAST, 'c'), {'a': 10, 'b': 10, 'c': 4})
((5, STORE_FAST, 'c'), {'a': 10, 'b': 10, 'c': 10})
output: a=10 b=10 c=10
Or specific opcodes:
>>> retro.implement(opcodes=['LOAD_CONST'], boundaries='finish')
>>> hello(40)
((3, LOAD_CONST, 1), {'a': 40, 'b': 2})
((4, LOAD_CONST, 2), {'a': 1, 'b': 2})
((5, LOAD_CONST, 2), {'a': 1, 'b': 2, 'c': 4})
((6, LOAD_CONST, 'output: a={} b={} c={}'), {'a': 10, 'b': 10, 'c': 10})
output: a=10 b=10 c=10
((7, RETURN_VALUE, None), {'a': 10, 'b': 10, 'c': 10})
Or return to exact original:
>>> retro.implement()
>>> hello(50)
output: a=10 b=10 c=10
Any of the above can be mixed as necessary, eg. lines=True, symbols="c"
Metadata
Release files for retrospect 0.1.4
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 |
|---|---|---|---|---|
| retrospect-0.1.4.tar.gz | 8.2 kB | Without provenance | Details for retrospect-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| retrospect-0.1.4-py2-none-any.whl | Python 2 | none | any | Details for retrospect-0.1.4-py2-none-any.whl |
Total release size: 18.6 kB
Release files / retrospect-0.1.4.tar.gz
| Download URL | retrospect-0.1.4.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c99b884caa7f08476cf5901167450dcd0ea6b5cfd88ef881a5146616bb4d7762
|
|
BLAKE2b-256 checksum How to use checksums |
2c8f76fa99ff48a1b07f08e9d30f7cbc3b3d1d036c40166bc4b8c2bb7a8442a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / retrospect-0.1.4-py2-none-any.whl
| Download URL | retrospect-0.1.4-py2-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
bb06771537eff97a0219eba8fb24f790d0ce088acd5c33ee6f121db6c3f1dafa
|
|
BLAKE2b-256 checksum How to use checksums |
fdd2ed9ab4edcd8dbf00cba6057e559948b13f53756cb605b27d5026aa2fe35c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for retrospect 0.1.4
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.