Fixing logging issues in music_functions.py and other_functions.py

This commit is contained in:
2025-01-31 19:30:48 +01:00
parent 993b303e2f
commit 323a1ac021
2 changed files with 16 additions and 11 deletions
+6 -4
View File
@@ -20,7 +20,6 @@ from constants import (
from spotify_dl import spotify
from spotify_dl import youtube as youtube_download
logger = logging.getLogger("discord")
class MusicFileList(object):
@@ -29,10 +28,11 @@ class MusicFileList(object):
file service or local directory and update the list with new items.
"""
def __init__(self, uplogger,) -> None:
def __init__(self, logger_name) -> None:
self.music_file_list = []
self.file_service_active = False
self.logger = uplogger
self.logger = logging.getLogger("discord")
self.logger.info("Created Playlist organizer class")
async def refresh_file_list(self, bot):
@@ -100,7 +100,7 @@ class MusicFileList(object):
requests.post(f"{FILE_SERVICE_ADDRESS}{SEND_MP3}", json=post_data, timeout=360)
MUSIC_FILE_LIST = MusicFileList(logger)
MUSIC_FILE_LIST = MusicFileList("discord")
async def get_file(ctx, source, link):
@@ -118,6 +118,7 @@ async def get_file(ctx, source, link):
:param link: The "link" parameter is likely a string that represents a URL or file path to the
location of the file that the function is trying to retrieve
"""
logger = logging.getLogger("discord")
item_id = None
item_type = None
file_list = []
@@ -288,6 +289,7 @@ async def search_music(ctx, how_many=0, slowa_kluczowe=None):
how_many, the function will return all search results, defaults to 0 (optional)
"""
# i sieć neuronową z możliwością wyrażenia opinii o dopasowaniu.
logger = logging.getLogger("discord")
if slowa_kluczowe:
word_list = slowa_kluczowe
else:
+10 -7
View File
@@ -1,6 +1,5 @@
import logging
# define an asynchronous generator
LOGGER = logging.getLogger("discord")
async def async_iterator_generator(range_of_iterable):
"""
@@ -89,26 +88,30 @@ async def get_stats(client, ctx, history_limit):
yield name, how_many
async def discord_friendly_reply(ctx, message_content, file=None):
logger = logging.getLogger("discord")
if len(message_content) < 999:
LOGGER.info("Answer reply - message below 999")
logger.info("Answer reply - message below 999")
await ctx.reply(message_content)
else:
LOGGER.info("Answer reply - message above 999")
logger.info("Answer reply - message above 999")
while len(message_content) > 0:
LOGGER.debug("Mesaage content: %s", message_content[:999])
logger.debug("Mesaage content: %s", message_content[:999])
await ctx.reply(message_content[:999])
message_content = message_content[999:]
if file:
await ctx.reply("Attachment:", file=file)
async def discord_friendly_send(ctx, message_content, file=None):
logger = logging.getLogger("discord")
if len(message_content) < 999:
LOGGER.info("Answer send - message below 999")
logger.info("Answer send - message below 999")
await ctx.send(message_content)
else:
LOGGER.info("Answer send - message above 999")
logger.info("Answer send - message above 999")
while len(message_content) > 0:
LOGGER.debug("Mesaage content: %s", message_content[:999])
logger.debug("Mesaage content: %s", message_content[:999])
await ctx.send(message_content[:999])
message_content = message_content[999:]
if file: