MaddieM4 / pymads

A fork of the pymds authoritative DNS server, designed for asynchronous lookup without domain restrictions.
GNU Lesser General Public License v3.0
4 stars 2 forks source link

Logging support #40

Closed pczarn closed 11 years ago

pczarn commented 11 years ago

Implements #34

pczarn commented 11 years ago

I corrected both design mistakes.

To do: tests, probably using logging.basicConfig(stream=StringIO.StringIO())

Perhaps more debugging information

DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 AAAA IN abcd::1234>
.DEBUG:server:Found <request question=[String('www'), String('theuselessweb'), String('com')] qtype=255 qclass=1>
 * <record for www.theuselessweb.com: 3600 CNAME IN www.theuselessweb.com.s3-website-us-east-1.amazonaws.com>
 * <record for www.theuselessweb.com.s3-website-us-east-1.amazonaws.com: 60 CNAME IN s3-website-us-east-1.amazonaws.com>
 * <record for s3-website-us-east-1.amazonaws.com: 60 A IN 205.251.242.131>
.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
..DEBUG:server:Unknown <request question=[String('sushi'), String('org')] qtype=255 qclass=1>
.DEBUG:server:Traceback (most recent call last):
  File "./pymads/consumer.py", line 75, in consume
    resp_pkt = self.make_response(req)
  File "./pymads/consumer.py", line 96, in make_response
    records = chain.get(req)
  File "./pymads/chain.py", line 44, in get
    return list(source(request))
  File "./pymads/chain.py", line 33, in get_from_sources
    for record in source.get(request):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_resolution.py", line 203, in get
    return 1/0
ZeroDivisionError: division by zero

.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=1 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
 * <record for example.com: 86400 A IN 93.184.216.119>
 * <record for example.com: 172800 NS IN b.iana-servers.net>
 * <record for example.com: 172800 NS IN a.iana-servers.net>
DEBUG:server:Found <request question=[String('example'), String('com')] qtype=1 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
 * <record for example.com: 86400 A IN 93.184.216.119>
 * <record for example.com: 172800 NS IN a.iana-servers.net>
 * <record for example.com: 172800 NS IN b.iana-servers.net>
.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 AAAA IN abcd::1234>
.DEBUG:server:Found <request question=[String('www'), String('theuselessweb'), String('com')] qtype=255 qclass=1>
 * <record for www.theuselessweb.com: 3600 CNAME IN www.theuselessweb.com.s3-website-us-east-1.amazonaws.com>
 * <record for www.theuselessweb.com.s3-website-us-east-1.amazonaws.com: 60 CNAME IN s3-website-us-east-1.amazonaws.com>
 * <record for s3-website-us-east-1.amazonaws.com: 60 A IN 205.251.242.131>
.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=255 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
..DEBUG:server:Unknown <request question=[String('sushi'), String('org')] qtype=255 qclass=1>
.DEBUG:server:Traceback (most recent call last):
  File "./pymads/consumer.py", line 75, in consume
    resp_pkt = self.make_response(req)
  File "./pymads/consumer.py", line 96, in make_response
    records = chain.get(req)
  File "./pymads/chain.py", line 44, in get
    return list(source(request))
  File "./pymads/chain.py", line 33, in get_from_sources
    for record in source.get(request):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_resolution.py", line 203, in get
    return 1/0
ZeroDivisionError: division by zero

.DEBUG:server:Found <request question=[String('example'), String('com')] qtype=1 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
 * <record for example.com: 86400 A IN 93.184.216.119>
 * <record for example.com: 172800 NS IN a.iana-servers.net>
 * <record for example.com: 172800 NS IN b.iana-servers.net>
DEBUG:server:Found <request question=[String('example'), String('com')] qtype=1 qclass=1>
 * <record for example.com: 1800 A IN 9.9.9.9>
 * <record for example.com: 86400 A IN 93.184.216.119>
 * <record for example.com: 172800 NS IN b.iana-servers.net>
 * <record for example.com: 172800 NS IN a.iana-servers.net>
...........WARNING:root:unknown record type SOA
.......DEBUG:server:Traceback (most recent call last):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_errors.py", line 85, in test_customerr
    raise Exception()
Exception

DEBUG:server:Traceback (most recent call last):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_errors.py", line 94, in test_customerr
    raise Exception('ABC')
Exception: ABC

DEBUG:server:Traceback (most recent call last):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_errors.py", line 103, in test_customerr
    raise Exception('ABC', 123)
Exception: ('ABC', 123)

.DEBUG:server:Traceback (most recent call last):
  File "/home/piotr/Desktop/src/pymads/pymads/tests/test_errors.py", line 64, in test_diverr
    return 1/0
ZeroDivisionError: division by zero

.......
----------------------------------------------------------------------
Ran 41 tests in 17.045s

OK
pczarn commented 11 years ago

This answers all your questions, I think.

Of course, some parts of code should log information, for example when rtype is unknown.

MaddieM4 commented 11 years ago

Sorry for the huge delay in reviewing your pull requests - I've had a lot of Big Life Stuff in the last few days, but I'm trying to catch up this week, if I can.

This code all looks great. There seems to be a superfluous import of "logging" in consumer.py (where we use self.server.logger), but I'll snip that out and make sure nothing unexpectedly breaks. Good job, @pczarn!