from sys import stdout from GeoffreyBot.geoffrey import * def setup_logging(): discord_logger = logging.getLogger('discord') discord_logger.setLevel(logging.INFO) bot_info_logger = logging.getLogger('GeoffreyBot') bot_info_logger.setLevel(logging.INFO) console = logging.StreamHandler(stdout) console.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) bot_info_logger.addHandler(console) def start_bot(discord_token, geoffrey_api_token, geoffrey_base_url): try: setup_logging() bot = GeoffreyBot(geoffrey_base_url, geoffrey_api_token) bot.run(discord_token) except KeyboardInterrupt: logger.info("Bot received keyboard interrupt") except Exception as e: print(e) logger.info('Bot encountered the following unhandled exception %s', e) finally: logger.info("Bot shutting down...")