Skip to content

Commit

Permalink
add utf-8 encoding to file handlers for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
k-boikov authored and p-i- committed Apr 16, 2023
1 parent 89e0e89 commit 4f33e1b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions autogpt/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ def __init__(self):
self.console_handler.setFormatter(console_formatter)

# Info handler in activity.log
self.file_handler = logging.FileHandler(os.path.join(log_dir, log_file))
self.file_handler = logging.FileHandler(
os.path.join(log_dir, log_file), 'a', 'utf-8'
)
self.file_handler.setLevel(logging.DEBUG)
info_formatter = AutoGptFormatter(
"%(asctime)s %(levelname)s %(title)s %(message_no_color)s"
)
self.file_handler.setFormatter(info_formatter)

# Error handler error.log
error_handler = logging.FileHandler(os.path.join(log_dir, error_file))
error_handler = logging.FileHandler(
os.path.join(log_dir, error_file), 'a', 'utf-8'
)
error_handler.setLevel(logging.ERROR)
error_formatter = AutoGptFormatter(
"%(asctime)s %(levelname)s %(module)s:%(funcName)s:%(lineno)d %(title)s"
Expand Down

1 comment on commit 4f33e1b

@zhangyangloucai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nihao

Please sign in to comment.