More precise verbose option: allow to choose between only the bot debug or both the bot and discord.py

This commit is contained in:
Elnath 2021-04-20 19:10:27 +02:00
parent f1e036eef9
commit 03c2f4ac1d
1 changed files with 9 additions and 2 deletions

View File

@ -301,15 +301,22 @@ if __name__ == '__main__':
argparser = argparse.ArgumentParser(description = "Discord bot to automatically create temporary voice channels for users when they connect to a special channel", formatter_class = argparse.ArgumentDefaultsHelpFormatter)
argparser.add_argument("-t", "--token-file", default = ".token", help = "File where the discord bot token is stored")
argparser.add_argument("-w", "--watched-channels-file", default = "channels.json", help = "Used to store the list of channels that the bot watches")
argparser.add_argument("-v", "--verbose", action = "store_true", help = "Print debug messages")
argparser.add_argument("-v", "--verbose", action = "count", default = 0, help = "Specify once to print bot debug messages, specify twice to print discord.py debug messages as well")
ARGS = argparser.parse_args()
logging.basicConfig(
level = logging.DEBUG if ARGS.verbose else logging.INFO,
format = "%(asctime)s %(name)s [%(levelname)s] %(message)s"
)
if ARGS.verbose == 0:
logging.root.setLevel(logging.INFO)
elif ARGS.verbose == 1:
logging.root.setLevel(logging.DEBUG)
logging.getLogger("discord").setLevel(logging.INFO)
else:
logging.root.setLevel(logging.DEBUG)
logger.info(f"Using discord.py version {discord.__version__}")
token_file_path = Path(ARGS.token_file).absolute()