logger stuff

This commit is contained in:
cwilvx
2024-12-31 13:56:40 +03:00
parent cbfe37a4ac
commit 2cc063ad76
2 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ class CustomFormatter(logging.Formatter):
return formatter.format(record) return formatter.format(record)
log = logging.getLogger("swing") log = logging.getLogger("SWING MUSIC")
log.propagate = False log.propagate = False
log.setLevel(logging.DEBUG) log.setLevel(logging.DEBUG)
+6 -5
View File
@@ -9,6 +9,7 @@ from app.utils.auth import get_current_userid
from app.utils.threading import background from app.utils.threading import background
from app.plugins import Plugin, plugin_method from app.plugins import Plugin, plugin_method
from app.logger import log
class LastFmPlugin(Plugin): class LastFmPlugin(Plugin):
def __init__(self): def __init__(self):
@@ -60,7 +61,7 @@ class LastFmPlugin(Plugin):
@plugin_method @plugin_method
@background @background
def scrobble(self, track: Track, timestamp: int): 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 = { data = {
"method": "track.scrobble", "method": "track.scrobble",
"artist": track.artists[0]["name"], "artist": track.artists[0]["name"],
@@ -70,11 +71,11 @@ class LastFmPlugin(Plugin):
"albumArtist": track.albumartists[0]["name"], "albumArtist": track.albumartists[0]["name"],
} }
print("scrobble data:", data) log.info(f"scrobble data: {data}")
try: try:
res = self.post(data) res = self.post(data)
print("scrobble response:", res.text) log.info("scrobble response:" + str(res.text))
print("scrobble response json:", res.json()) log.info("scrobble response json:" + str(res.json()))
except Exception as e: except Exception as e:
print("scrobble error", e) log.info("scrobble error" + str(e))