mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Setup coloredlogs
This commit is contained in:
@@ -1,16 +1,37 @@
|
||||
import logzero
|
||||
import logging
|
||||
for module in ("urllib3", "spotipy", "pytube",):
|
||||
logging.getLogger(module).setLevel(logging.CRITICAL)
|
||||
|
||||
import coloredlogs
|
||||
coloredlogs.DEFAULT_FIELD_STYLES = {
|
||||
"levelname": {"bold": True, "color": "yellow"},
|
||||
"name": {"color": "blue"},
|
||||
"lineno": {"color": "magenta"},
|
||||
}
|
||||
|
||||
import sys
|
||||
|
||||
from spotdl import command_line
|
||||
def set_logger(level):
|
||||
if level == logging.DEBUG:
|
||||
fmt = "%(levelname)s:%(name)s:%(lineno)d:\n%(message)s"
|
||||
else:
|
||||
fmt = "%(levelname)s: %(message)s"
|
||||
logging.basicConfig(format=fmt, level=level)
|
||||
logger = logging.getLogger(name=__name__)
|
||||
coloredlogs.install(level=level, fmt=fmt, logger=logger)
|
||||
return logger
|
||||
|
||||
|
||||
def main():
|
||||
arguments = command_line.get_arguments()
|
||||
spotdl = command_line.Spotdl(arguments.__dict__)
|
||||
from spotdl.command_line.arguments import get_arguments
|
||||
arguments = get_arguments()
|
||||
logger = set_logger(arguments["log_level"])
|
||||
from spotdl.command_line.lib import Spotdl
|
||||
spotdl = Spotdl(arguments)
|
||||
try:
|
||||
spotdl.match_arguments()
|
||||
except KeyboardInterrupt as e:
|
||||
logzero.logger.exception(e)
|
||||
logger.exception(e)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user