Skip to content

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

Merged
auvipy merged 1 commit into
masterfrom
logger-utf-8-encoding
Sep 28, 2020
Merged

Specify utf-8 as the encoding for log files.#6357
auvipy merged 1 commit into
masterfrom
logger-utf-8-encoding

Conversation

@thedrow

@thedrow thedrow commented Sep 21, 2020

Copy link
Copy Markdown
Contributor

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

Description

Fixes #5144.

@thedrow

thedrow commented Sep 21, 2020

Copy link
Copy Markdown
Contributor Author

@kyungSong @sihrc does this resolve your problem?

@lgtm-com

lgtm-com Bot commented Sep 21, 2020

Copy link
Copy Markdown

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
Copy Markdown

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

auvipy commented Sep 25, 2020

Copy link
Copy Markdown
Member

did you check this?

Comment thread celery/app/log.py
if hasattr(logfile, 'write'):
return logging.StreamHandler(logfile)
return WatchedFileHandler(logfile)
return WatchedFileHandler(logfile, encoding='utf-8')

@georgepsarakis georgepsarakis Sep 27, 2020

Copy link
Copy Markdown
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
Copy Markdown

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!

@auvipy auvipy left a comment

Copy link
Copy Markdown
Member

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