jgarzik / python-bitcoinrpc

Python interface to bitcoin's JSON-RPC API
GNU Lesser General Public License v2.1
644 stars 304 forks source link

Add optional logging of all RPC communication #31

Closed gavinandresen closed 9 years ago

gavinandresen commented 10 years ago

More convenient than figuring out how to insert wireshark into the RPC communication path.

Logging the RPC calls and results made can be useful when debugging problems. This uses the standard python logging module; simple usage to trace all RPC calls to stderr:

import logging
logging.basicConfig()
logging.getLogger("BitcoinRPC").setLevel(logging.DEBUG)

Example logging output:

>>> c = AuthServiceProxy("http://u:p@127.0.0.1:18332")
>>> c.getinfo()
DEBUG:BitcoinRPC:-1-> getinfo []
DEBUG:BitcoinRPC:<-1- {"connections": 8, ...etc }

>>> c.setgenerate(True, 2)
DEBUG:BitcoinRPC:-2-> setgenerate [true, 2]
DEBUG:BitcoinRPC:<-2- null

>>> c.setgenerate(True, Decimal('2'))
DEBUG:BitcoinRPC:-3-> setgenerate [true, 2.0]
DEBUG:BitcoinRPC:<-- {"result":null,"error":{"code":-1,"message":"value is type real, expected int"},"id":3}

Depends on #29 and #30

jgarzik commented 10 years ago

ACK, but says there are merge conflicts after merging #29

gavinandresen commented 10 years ago

Merge conflict fixed... and improved the README