fixed bug where newlines were not being handled correctly in logging

This commit is contained in:
phixxy 2024-02-06 01:52:03 -08:00
parent 225e715639
commit 346a6b0298
2 changed files with 4 additions and 3 deletions

View file

@ -238,7 +238,8 @@ class ChatGPT(commands.Cog):
await self.download_image(image_url, image_filepath) await self.download_image(image_url, image_filepath)
with open(image_filepath, "rb") as fh: with open(image_filepath, "rb") as fh:
f = discord.File(fh, filename=image_filepath) f = discord.File(fh, filename=image_filepath)
log_data = f'Author: {ctx.author.name}, Prompt: {prompt.replace('\n',' ')}, Filename: {my_filename}\n' prompt = prompt.replace('\n',' ')
log_data = f'Author: {ctx.author.name}, Prompt: {prompt}, Filename: {my_filename}\n'
with open(f"{self.data_dir}logs/dalle3.log", 'a') as log_filepath: with open(f"{self.data_dir}logs/dalle3.log", 'a') as log_filepath:
log_filepath.writelines(log_data) log_filepath.writelines(log_data)
await ctx.send(f'Generated by: {ctx.author.name}\nPrompt: {prompt}', file=f) await ctx.send(f'Generated by: {ctx.author.name}\nPrompt: {prompt}', file=f)

View file

@ -254,8 +254,8 @@ class StableDiffusion(commands.Cog):
with open(filepath, "rb") as fh: with open(filepath, "rb") as fh:
f = discord.File(fh, filename=filepath) f = discord.File(fh, filename=filepath)
prompt = prompt.replace('\n',' ')
log_data = f'Author: {ctx.author.name}, Prompt: {prompt.replace('\n',' ')}, Filename: {my_filename}\n' log_data = f'Author: {ctx.author.name}, Prompt: {prompt}, Filename: {my_filename}\n'
with open(f"{self.data_dir}stable_diffusion.log", 'a') as log_file: with open(f"{self.data_dir}stable_diffusion.log", 'a') as log_file:
log_file.writelines(log_data) log_file.writelines(log_data)