Skip to content

Commit

Permalink
Fixing and cleaning code
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Dec 22, 2024
1 parent acf6e0e commit ddd23f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions sausage_bot/util/db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions sausage_bot/util/log/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}) '\
Expand Down Expand Up @@ -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
):
Expand Down Expand Up @@ -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')

0 comments on commit ddd23f2

Please sign in to comment.