Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify utf-8 as the encoding for log files. #6357

Merged
merged 1 commit into from Sep 28, 2020
Merged

Conversation

thedrow
Copy link
Member

@thedrow thedrow commented Sep 21, 2020

Note: Before submitting this pull request, please review our contributing
guidelines
.

Description

Fixes #5144.

@thedrow
Copy link
Member Author

thedrow commented Sep 21, 2020

@kyungSong @sihrc does this resolve your problem?

@lgtm-com
Copy link

lgtm-com bot commented Sep 21, 2020

This pull request fixes 1 alert when merging 1b30740 into 5a0c458 - view on LGTM.com

fixed alerts:

  • 1 for Non-exception in 'except' clause

@kyungSong
Copy link

I'll have to test and get back to you on this. I'll comment as soon as I find out if this fix works

@auvipy
Copy link
Member

auvipy commented Sep 25, 2020

did you check this?

@@ -221,7 +221,7 @@ def _detect_handler(self, logfile=None):
logfile = sys.__stderr__ if logfile is None else logfile
if hasattr(logfile, 'write'):
return logging.StreamHandler(logfile)
return WatchedFileHandler(logfile)
return WatchedFileHandler(logfile, encoding='utf-8')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a problem for existing log files? Other than that it would seem to cover most use cases. Maybe in the future it could become a setting.

@kyungSong
Copy link

hey, sorry for the late response, work was slamming this week.

Yes, this solved it! (was using redis as backend, celery version 4.1.1) Thanks a bunch!

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

lgtm for now

@auvipy auvipy merged commit ea37db1 into master Sep 28, 2020
@auvipy auvipy deleted the logger-utf-8-encoding branch September 28, 2020 03:46
@thedrow thedrow added this to the 5.0.1 milestone Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logger set to 'ascii' instead of 'utf-8': UnicodeDecodeError 'ascii'
4 participants