From ddd23f2a43f4059706d3283f0a42675a32ee0d4f Mon Sep 17 00:00:00 2001 From: geirawsm Date: Sun, 22 Dec 2024 23:17:34 +0100 Subject: [PATCH] Fixing and cleaning code --- sausage_bot/util/db_helper.py | 8 ++++---- sausage_bot/util/log/log.py | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sausage_bot/util/db_helper.py b/sausage_bot/util/db_helper.py index bd1d552..1c2d40c 100755 --- a/sausage_bot/util/db_helper.py +++ b/sausage_bot/util/db_helper.py @@ -91,10 +91,10 @@ async def prep_table( 'This should be looked into, so messaging the bot-dump' ) await discord_commands.log_to_bot_channel( - content_in='Want to insert info from old json into ' - f'{table_name}, but something is wrong' - '({} vs {})'.format( - db_len, len(inserts) + content_in='Want to insert info from old json or inserts into ' + f'`{table_name}` in `{db_file}`, but something is wrong' + '({} vs {})\nInserts:\n{}'.format( + db_len, len(inserts), inserts ) ) delete_json_ok = False diff --git a/sausage_bot/util/log/log.py b/sausage_bot/util/log/log.py index 82e1a70..33e8c85 100755 --- a/sausage_bot/util/log/log.py +++ b/sausage_bot/util/log/log.py @@ -58,13 +58,12 @@ def log_function( else: extra_color = eval('Fore.{}'.format(extra_color.upper())) function_name = log_func_name() - if args.log_print: - if args.log_highlight is not None: - if str(args.log_highlight) in function_name['name'] or\ - str(args.log_highlight) in log_in: - color = eval('Fore.{}'.format( - args.log_highlight_color.upper() - )) + if args.log_print and args.log_highlight is not None and\ + str(args.log_highlight) in function_name['name'] or\ + str(args.log_highlight) in log_in: + color = eval('Fore.{}'.format( + args.log_highlight_color.upper() + )) dt = pendulum.now(config.TIMEZONE) dt_full = dt.format('DD.MM.YYYY HH.mm.ss') log_out = '[ {dt} ]{extra_info} [ {func_name} ({func_line}) '\ @@ -171,7 +170,7 @@ def verbose( def debug( log_in: str, color: str = None, - extra_info: str = envs.log_extra_info('database'), + extra_info: str = envs.log_extra_info('debug'), extra_color: str = None, pretty: dict | list | tuple = None, sameline: bool = False ): @@ -289,12 +288,17 @@ def log_func_name() -> dict: if __name__ == "__main__": args.log_print = True args.log = True + print('This should produce "This is a log"') log('This is a log') args.log_verbose = True + print('This should produce "This is a verbose"') verbose('This is a verbose') args.debug = True + print('This should produce "This is a debug"') debug('This is a debug') args.log_db = True + print('This should produce "This is a db"') db('This is a db') args.log_error = True + print('This should produce "This is a error"') error('This is an error')