From 835f7491ed7a99f5e4feee474db1aff893751056 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 22 Nov 2014 17:11:58 +0100 Subject: logging --- imdb-lookup/imdbinfo.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/imdb-lookup/imdbinfo.py b/imdb-lookup/imdbinfo.py index 70d2790..bb720ef 100755 --- a/imdb-lookup/imdbinfo.py +++ b/imdb-lookup/imdbinfo.py @@ -36,6 +36,7 @@ class TMDBCache(object): def __enter__(self): self.db = dbm.open(self._get_db_filename("tmdbmovie.dbm"),"c") self.db_images = dbm.open(self._get_db_filename("tmdbposter.dbm"), "c") + self.logger = logging.getLogger(self.__class__.__module__ + "." + self.__class__.__name__) return self def __exit__(self, type, value, traceback): @@ -51,14 +52,13 @@ class TMDBCache(object): def _cache(self, key, callable_func): if key not in self.db: - logging.info("Load value for key %s", key) self.db[key] = json.dumps(callable_func()) d = self.db[key].decode('utf-8') return json.loads(d) def infos(self, movie_id): try: - logging.debug("movie %s", movie_id) + self.logger.debug("movie %s", movie_id) return self._cache(movie_id + "movies.info", tmdb.Movies(movie_id).info) except Exception as e: raise Exception("Failed to query movie with id {id}: {reason}".format(id=movie_id, reason=str(e))) @@ -84,12 +84,11 @@ class TMDBCache(object): del self.db[key] def poster(self, poster_path, format="w185"): - logging.debug("poster %s", poster_path) + self.logger.debug("poster %s", poster_path) key = "poster_{}_{}".format(format, poster_path) keyContentType = "poster_{}_{}_content_type".format(format, poster_path) url = "http://image.tmdb.org/t/p/{}/{}".format(format, poster_path) if key not in self.db_images: - logging.info("Load poster %s", url) r = requests.get(url) self.db_images[key] = r.content self.db_images[keyContentType] = r.headers['content-type'] -- cgit v1.2.1