diff options
author | Random Hacker <random_hacker@xapek.org> | 2010-08-27 19:45:28 +0200 |
---|---|---|
committer | Random Hacker <random_hacker@xapek.org> | 2010-08-27 19:45:28 +0200 |
commit | 842a845c199726629f1ac45f8b06312d2e78423b (patch) | |
tree | 14335574e11672c4ef3312bd05ff7d1b170f6cf1 | |
parent | de1bbfc28dd9dcc76f8d4a34e1524b1f3a594fdb (diff) | |
download | ebus-alt-842a845c199726629f1ac45f8b06312d2e78423b.tar.gz ebus-alt-842a845c199726629f1ac45f8b06312d2e78423b.zip |
use logger
-rw-r--r-- | ebus/__init__.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ebus/__init__.py b/ebus/__init__.py index 7b8c8ed..a435e76 100644 --- a/ebus/__init__.py +++ b/ebus/__init__.py @@ -3,11 +3,15 @@ import asynchat import asyncore import socket import sys +import logging import os from lxml import objectify from lxml import etree +logger = logging.getLogger("ebus.core") +logger.setLevel(logging.INFO) + class UnknownPacketException(Exception): pass @@ -122,7 +126,7 @@ class EbusReader(asynchat.async_chat): i = i + 1 if len(data) < 2: - print "GAGA" + logger.critical("Daten Gaga") return source = ord(data[0]) sourceType = EbusPacket.address_to_type(source) @@ -130,7 +134,7 @@ class EbusReader(asynchat.async_chat): destinationType = EbusPacket.address_to_type(destination) if len(data) < 9: - print >>sys.stderr, "Unvollständige Daten" + logger.critical("Unvollständige Daten") return primaryCommand = ord(data[2]) @@ -154,15 +158,15 @@ class EbusReader(asynchat.async_chat): self.handle_ebus(p) elif sourceType == 'master' and destinationType == 'slave': p = EbusMasterSlave(source, destination, primaryCommand, secondaryCommand, payload, None) #FIXME - print >>sys.stderr, "SKIP MASTER-SLAVE" + logger.info("SKIP MASTER-SLAVE") elif sourceType == 'master' and destinationType == 'broadcast': p = EbusBroadcast(source, destination, primaryCommand, secondaryCommand, payload) self.handle_ebus(p) else: - print >>sys.stderr, "SKIP source=%s sourceType=%s destination=%s destType=%s" % \ - (source, sourceType, destination, destinationType) + logger.warning("SKIP source=%s sourceType=%s destination=%s destType=%s" % \ + (source, sourceType, destination, destinationType)) except UnknownPacketException,e: print e def handle_ebus(self,ebus_packet): - print >>sys.stderr, "unhandled ebus_packet" + logger.critical("unhandled ebus_packet") |