mirror of
https://github.com/Dineshkarthik/telegram_media_downloader.git
synced 2025-01-09 03:58:20 +08:00
refactor: improve logging
This commit is contained in:
parent
1f0c45cd2d
commit
42118052bd
@ -9,12 +9,13 @@ import pyrogram
|
||||
import yaml
|
||||
|
||||
from utils.file_management import get_next_name, manage_duplicate_file
|
||||
from utils.log import LogFilter
|
||||
from utils.meta import print_meta
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.getLogger("pyrogram.session.session.send").setLevel(
|
||||
logging.CRITICAL + 1
|
||||
)
|
||||
logging.getLogger("pyrogram.session.session").addFilter(LogFilter())
|
||||
logging.getLogger("pyrogram.client").addFilter(LogFilter())
|
||||
logger = logging.getLogger("media_downloader")
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
@ -171,9 +172,6 @@ async def download_media(
|
||||
_media, _type
|
||||
)
|
||||
if _can_download(_type, file_formats, file_format):
|
||||
logger.info(
|
||||
"Message[%d]: downloading...", message.message_id
|
||||
)
|
||||
if _is_exist(file_name):
|
||||
file_name = get_next_name(file_name)
|
||||
download_path = await client.download_media(
|
||||
|
15
utils/log.py
Normal file
15
utils/log.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""Util module to handle logs."""
|
||||
import logging
|
||||
|
||||
|
||||
class LogFilter(logging.Filter):
|
||||
"""
|
||||
Custom Log Filter.
|
||||
|
||||
Ignore logs from specific functions.
|
||||
"""
|
||||
# pylint: disable = W0221
|
||||
def filter(self, log_record):
|
||||
if log_record.funcName == "send" or log_record.funcName == "get_file":
|
||||
return False
|
||||
return True
|
Loading…
Reference in New Issue
Block a user