ionelmc / python-hunter

Hunter is a flexible code tracing toolkit.
https://python-hunter.readthedocs.io/
BSD 2-Clause "Simplified" License
800 stars 46 forks source link

Are multiple actions directed to a stream possible? #75

Closed c-amow closed 4 years ago

c-amow commented 4 years ago

Thanks for this project, great work!

Is it possible to combine code and variables to a stream, when I try this I don't get the variables - but there are no complaints:

logstream = open("test.log", "w")
hunter.trace(Q(function='fun1')|Q(module='subdemo'),
             Q(action=hunter.CallPrinter(stream=logstream))|Q(action=hunter.VarsPrinter('x','z', stream=logstream)) )
ionelmc commented 4 years ago

Your actions aren't running properly because they are treated as filter. Try this instead:

hunter.trace(
    Q(function='fun1')|Q(module='subdemo'),
    actions=[hunter.CallPrinter(stream=logstream)),
             hunter.VarsPrinter('x','z', stream=logstream))]
)
c-amow commented 4 years ago

@ionelmc Awesome - thank you very much!