diff options
author | Mike Crute <mike@crute.us> | 2017-09-30 22:48:43 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2017-09-30 23:09:18 +0000 |
commit | 2f41ed30de870877cb9f5910db924ba1b1f06c83 (patch) | |
tree | 77f469858690a242c24032a24cf9d4b3c7a654fa | |
parent | 251eac4e987e241798b12f271f0cd4af24173d3e (diff) | |
download | pydora-2f41ed30de870877cb9f5910db924ba1b1f06c83.tar.bz2 pydora-2f41ed30de870877cb9f5910db924ba1b1f06c83.tar.xz pydora-2f41ed30de870877cb9f5910db924ba1b1f06c83.zip |
Add logging to player
Also adds -v argument to the pydora player to enable debug logging. May
add more logging later as it becomes useful.
-rw-r--r-- | pydora/audio_backend.py | 8 | ||||
-rw-r--r-- | pydora/player.py | 13 |
2 files changed, 20 insertions, 1 deletions
diff --git a/pydora/audio_backend.py b/pydora/audio_backend.py index f92998a..1adf0a3 100644 --- a/pydora/audio_backend.py +++ b/pydora/audio_backend.py | |||
@@ -3,11 +3,15 @@ import time | |||
3 | import fcntl | 3 | import fcntl |
4 | import select | 4 | import select |
5 | import socket | 5 | import socket |
6 | import logging | ||
6 | 7 | ||
7 | from pandora.py2compat import which | 8 | from pandora.py2compat import which |
8 | from .utils import iterate_forever, SilentPopen | 9 | from .utils import iterate_forever, SilentPopen |
9 | 10 | ||
10 | 11 | ||
12 | log = logging.getLogger("pydora.audio_backend") | ||
13 | |||
14 | |||
11 | class PlayerException(Exception): | 15 | class PlayerException(Exception): |
12 | """Base class for all player exceptions | 16 | """Base class for all player exceptions |
13 | """ | 17 | """ |
@@ -139,6 +143,7 @@ class BasePlayer(object): | |||
139 | if not getattr(self, "_cmd"): | 143 | if not getattr(self, "_cmd"): |
140 | raise RuntimeError("Player command is not configured") | 144 | raise RuntimeError("Player command is not configured") |
141 | 145 | ||
146 | log.debug("Starting playback command: %r", self._cmd) | ||
142 | self._process = SilentPopen(self._cmd) | 147 | self._process = SilentPopen(self._cmd) |
143 | self._post_start() | 148 | self._post_start() |
144 | 149 | ||
@@ -211,6 +216,7 @@ class MPG123Player(BasePlayer): | |||
211 | if not loc: | 216 | if not loc: |
212 | raise PlayerUnusable("Unable to find mpg123") | 217 | raise PlayerUnusable("Unable to find mpg123") |
213 | 218 | ||
219 | log.info("Using mpg123 at path %s", loc) | ||
214 | return loc | 220 | return loc |
215 | 221 | ||
216 | def _load_track(self, song): | 222 | def _load_track(self, song): |
@@ -246,6 +252,7 @@ class VLCPlayer(BasePlayer): | |||
246 | if not loc: | 252 | if not loc: |
247 | raise PlayerUnusable("Unable to find VLC") | 253 | raise PlayerUnusable("Unable to find VLC") |
248 | 254 | ||
255 | log.info("Using vlc at location %s", loc) | ||
249 | return loc | 256 | return loc |
250 | 257 | ||
251 | def raise_volume(self): | 258 | def raise_volume(self): |
@@ -300,6 +307,7 @@ class RemoteVLC(VLCPlayer): | |||
300 | 307 | ||
301 | def _ensure_started(self): | 308 | def _ensure_started(self): |
302 | if not self._control_sock: | 309 | if not self._control_sock: |
310 | log.debug("Connecting to remote VLC at %r", self._connect_to) | ||
303 | self._control_sock = socket.create_connection(self._connect_to) | 311 | self._control_sock = socket.create_connection(self._connect_to) |
304 | self._control_sock.setblocking(False) | 312 | self._control_sock.setblocking(False) |
305 | 313 | ||
diff --git a/pydora/player.py b/pydora/player.py index 128674b..3ff56dd 100644 --- a/pydora/player.py +++ b/pydora/player.py | |||
@@ -10,6 +10,7 @@ from __future__ import print_function | |||
10 | 10 | ||
11 | import os | 11 | import os |
12 | import sys | 12 | import sys |
13 | import logging | ||
13 | import argparse | 14 | import argparse |
14 | from pandora import clientbuilder | 15 | from pandora import clientbuilder |
15 | 16 | ||
@@ -253,10 +254,20 @@ class PlayerApp(object): | |||
253 | parser.add_argument( | 254 | parser.add_argument( |
254 | "--vlc-net", dest="vlc_net", | 255 | "--vlc-net", dest="vlc_net", |
255 | help="connect to VLC over the network (host:port)") | 256 | help="connect to VLC over the network (host:port)") |
257 | parser.add_argument( | ||
258 | "-v", dest="verbose", action="store_true", | ||
259 | help="enable verbose logging") | ||
256 | return parser.parse_args() | 260 | return parser.parse_args() |
257 | 261 | ||
258 | def run(self): | 262 | def run(self): |
259 | self.player = self.get_player(self._parse_args().vlc_net) | 263 | args = self._parse_args() |
264 | |||
265 | if args.verbose: | ||
266 | logging.basicConfig(level=logging.DEBUG) | ||
267 | else: | ||
268 | logging.basicConfig(level=logging.ERROR) | ||
269 | |||
270 | self.player = self.get_player(args.vlc_net) | ||
260 | self.player.start() | 271 | self.player.start() |
261 | 272 | ||
262 | self.client = self.get_client() | 273 | self.client = self.get_client() |