From 2cc063ad7643259d8f1b52d41dce8f8b40a7c396 Mon Sep 17 00:00:00 2001 From: cwilvx Date: Tue, 31 Dec 2024 13:56:40 +0300 Subject: [PATCH] logger stuff --- app/logger.py | 2 +- app/plugins/lastfm.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/logger.py b/app/logger.py index 3df7cd7d..847680bd 100644 --- a/app/logger.py +++ b/app/logger.py @@ -35,7 +35,7 @@ class CustomFormatter(logging.Formatter): return formatter.format(record) -log = logging.getLogger("swing") +log = logging.getLogger("SWING MUSIC") log.propagate = False log.setLevel(logging.DEBUG) diff --git a/app/plugins/lastfm.py b/app/plugins/lastfm.py index 1c4587a4..b25609ea 100644 --- a/app/plugins/lastfm.py +++ b/app/plugins/lastfm.py @@ -9,6 +9,7 @@ from app.utils.auth import get_current_userid from app.utils.threading import background from app.plugins import Plugin, plugin_method +from app.logger import log class LastFmPlugin(Plugin): def __init__(self): @@ -60,7 +61,7 @@ class LastFmPlugin(Plugin): @plugin_method @background def scrobble(self, track: Track, timestamp: int): - print("Last.fm: logging track: ", track.title, "-", track.artists[0]["name"]) + log.info(f"Last.fm: logging track: {track.title} - {track.artists[0]['name']}") data = { "method": "track.scrobble", "artist": track.artists[0]["name"], @@ -70,11 +71,11 @@ class LastFmPlugin(Plugin): "albumArtist": track.albumartists[0]["name"], } - print("scrobble data:", data) + log.info(f"scrobble data: {data}") try: res = self.post(data) - print("scrobble response:", res.text) - print("scrobble response json:", res.json()) + log.info("scrobble response:" + str(res.text)) + log.info("scrobble response json:" + str(res.json())) except Exception as e: - print("scrobble error", e) + log.info("scrobble error" + str(e))