Skip to content

Default to UTF-8 in /var/log/cloud-init.log#427

Merged
OddBloke merged 2 commits into
canonical:masterfrom
TheRealFalcon:utf8-logging
Jun 12, 2020
Merged

Default to UTF-8 in /var/log/cloud-init.log#427
OddBloke merged 2 commits into
canonical:masterfrom
TheRealFalcon:utf8-logging

Conversation

@TheRealFalcon
Copy link
Copy Markdown
Contributor

On a system with a non-utf8 default locale, the logger will silently not log anything if the message contains an unsupported character.

Specifically on Xenial, in the cloud-init process

import locale
print(locale.getpreferredencoding())

returns ANSI_X3.4-1968.

Interesting to note, running the same code on the CLI after cloud-init has completed returns UTF-8.

The StreamLogger (i.e., the stdout/stderr logger) suffers from the same problem, but there's no (non-hacky) way to alter its encoding.

On a system with a non-utf8 default locale, the logger will silently
not log anything if the message contains an unsupported character.
@smoser
Copy link
Copy Markdown
Collaborator

smoser commented Jun 12, 2020

Kind of just for reference... LP: #1751051.

The world is a strange place before there is a system locale set. That is the world in which you're first opening the log.

I'm sorry if this isn't relevant information, but it felt like it might be.

@OddBloke
Copy link
Copy Markdown
Collaborator

@smoser Agreed that it's a weird world at this point, and thanks for the context; I double-checked with Steve Langasek and he also couldn't think of a reason to not open it in UTF-8.

Copy link
Copy Markdown
Collaborator

@OddBloke OddBloke left a comment

Choose a reason for hiding this comment

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

Thanks!

@OddBloke OddBloke merged commit 287bfca into canonical:master Jun 12, 2020
Copy link
Copy Markdown
Contributor

@xnox xnox left a comment

Choose a reason for hiding this comment

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

Ship it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants