diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-01-17 13:23:02 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-01-17 13:23:02 +0100 |
commit | 0ef8e9b7c6a154f109315a2f597f20f94f65f1b7 (patch) | |
tree | f6003e5547d223517e52a723bdf80196d63802c0 | |
parent | f6c2485f49613617605474ba7ef2a78471ba1fd0 (diff) | |
download | mpd-box-0ef8e9b7c6a154f109315a2f597f20f94f65f1b7.tar.gz mpd-box-0ef8e9b7c6a154f109315a2f597f20f94f65f1b7.tar.xz |
daemon: add some proper loggin support
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | daemon.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -4,6 +4,11 @@ import serial import mpd import time import sys +import logging + +logger = logging.getLogger() +logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") +logger.setLevel(logging.DEBUG) class Config: display_lines = 2 @@ -30,6 +35,7 @@ class Daemon: self.client = mpd.MPDClient() self.client.connect("localhost", 6600) + logger.debug("connected") def readline(self): return self.ser.readline().decode("ascii").strip() @@ -67,6 +73,8 @@ class Daemon: if self.ser.inWaiting() > 0: incoming = self.readline() + logger.info("got serial command: '%s'", incoming) + functions = { "next": self.client.next, "previous": self.client.previous, @@ -82,6 +90,7 @@ class Daemon: current_position = 0 except KeyError: + logger.warning("ignoring unknown serial command '%s'", incoming) pass # check if song changed @@ -120,7 +129,7 @@ class Daemon: # always start at the beginning if we unpause current_position = 0 - print("'" + buf + "'") + logger.debug("current_position = %s, buf = '%s'", str(current_position).rjust(3), buf) self.ser.write(bytes(buf, "ascii", "replace")) time.sleep(0.05) |