Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide basic logging and DEBUG, INFO messages #34

Closed
fatuhoku opened this issue Sep 27, 2013 · 2 comments
Closed

Provide basic logging and DEBUG, INFO messages #34

fatuhoku opened this issue Sep 27, 2013 · 2 comments

Comments

@fatuhoku
Copy link

Not sure if other Pythonistas do this, but I work like this these days:

  • write a test (possibly using VCRpy!) with tactical sprinkle of logger.debug() bits of info
  • run it
  • it fails; I see the useful debug trace leading up to failure (which may be an exception, etc.)
  • tweak the test / the source code
  • re-run the test... etc.
  • rinse and repeat

I expect libraries and tools I use to provide me useful logging debug information. When I turn the log level to DEBUG I should see important decisions that VCRpy has made, such as

  1. when a request is detected
  2. how exactly vcrpy decided to supply the response:
    What fields of the request did it try to match?
    Could it find any matches in the known cassettes?
    If so, which one? Which exact request?
    If not, the request hits the network. How long did the request take to complete?

This is really important especially now that vcrpy has become much more powerful with customisable request matching. There are many more ways in which it could behave not quite as the user anticipated. e.g. I know that two distinct requests were sent and both were supposed to hit the network. I found that the request matching was too broad. I want debugging to tell me this so that I can make informed decisions about how to improve my test.

I imagine a few lines like this at strategic places in vcrpy code:

logger = logging.getLogger('vcrpy')

# in vcrpy code
logger.debug("Found matching request {1} in cassette {0}. Playing back...".format(cassette, request))
@kevin1024
Copy link
Owner

Interesting idea, I'll think about the best way to do this. I think using a null output logger by default and then providing a way to get logging output if you want it.

@fatuhoku
Copy link
Author

fatuhoku commented Oct 1, 2013

Aye, definitely provide a NullHandler by default. That is the convention for libraries I think =]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants