diff --git a/geoffrey/BotConfig.py b/geoffrey/BotConfig.py index 5d99d90..8b044e3 100644 --- a/geoffrey/BotConfig.py +++ b/geoffrey/BotConfig.py @@ -19,7 +19,8 @@ def create_config(config, path): config['Minecraft'] = {'Dynmap_Url': '', 'World_Name': '', } - config['Logging'] = {'Count': '7', + config['Logging'] = {'Log_Path': '', + 'Count': '7', 'Rotation_Duration': '1' } config['Special Names'] = {} @@ -58,6 +59,7 @@ class Config: self.dynmap_url = self.config['Minecraft']['Dynmap_Url'] + self.log_path = self.config['Logging']['log_path'] self.count = int(self.config['Logging']['Count']) self.rotation_duration = int(self.config['Logging']['Rotation_Duration']) self.special_name_list = dict(self.config.items('Special Names')) diff --git a/geoffrey/bot.py b/geoffrey/bot.py index 00b86c8..58f49fb 100644 --- a/geoffrey/bot.py +++ b/geoffrey/bot.py @@ -107,10 +107,10 @@ class GeoffreyBot(commands.Bot): if error_str is '': await self.send_error_message( 'Geoffrey encountered unhandled exception: {}. Context:'.format(error, ctx.args)) - - logger.error("Geoffrey encountered unhandled exception: %s", error) error_str = bad_error_message.format(ctx.invoked_with) + logger.error("Geoffrey encountered exception: %s", error) + await self.send_message(ctx.message.channel, '{} **Error Running Command:** {}'.format( ctx.message.author.mention, error_str)) @@ -146,16 +146,16 @@ async def username_update(bot): def setup_logging(config): - discord_logger = logging.getLogger('discord') discord_logger.setLevel(logging.INFO) sql_logger = logging.getLogger('sqlalchemy.engine') sql_logger.setLevel(logging.INFO) bot_info_logger = logging.getLogger('geoffrey.bot') bot_info_logger.setLevel(logging.INFO) + log_path = path.abspath(config.log_path) - handler = handlers.TimedRotatingFileHandler(filename="{}/Geoffrey.log".format(path.dirname(path.abspath(__file__))), - when='D', interval=config.rotation_duration, backupCount=config.count, + handler = handlers.TimedRotatingFileHandler(filename="{}/Geoffrey.log".format(log_path), when='D', + interval=config.rotation_duration, backupCount=config.count, encoding='utf-8') handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) diff --git a/geoffrey/cogs/Search_Commands.py b/geoffrey/cogs/Search_Commands.py index 584b30e..4ac2c58 100644 --- a/geoffrey/cogs/Search_Commands.py +++ b/geoffrey/cogs/Search_Commands.py @@ -131,7 +131,6 @@ class Search_Commands: """ Displays all your locations in the database """ - try: loc_str = self.bot.bot_commands.me(discord_uuid=ctx.message.author.id) await self.bot.say('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,