Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Log with 20/20 vision

Project Description

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"

Release History

Release History

This version
History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

History Node

0.0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
retrospect-0.1.4-py2-none-any.whl (10.3 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Oct 12, 2015
retrospect-0.1.4.tar.gz (8.2 kB) Copy SHA256 Checksum SHA256 Source Oct 12, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting