Skip to content

Conversation

@wesleybowman
Copy link
Contributor

Removed mid variable from JournalHandler since the MESSAGE_ID is already
in the extras variable. MESSAGE_ID was being set to None, but this won't
appear in the logs.

Copy link
Member

@keszybz keszybz left a comment

Choose a reason for hiding this comment

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

Looks reasonable, but can you please split the style fixes out as a separate commit from the mid change?


@staticmethod
def mapPriority(levelno):
def map_priority(levelno):
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree that map_priority is a much better name. This part of the code is very old, it even predates the time when python-systemd was in the systemd repo. Hence the style that is a bit strange.

But I think we must keep backwards compatibility here. Can you add mapPriority = map_priority or something like that?

@wesleybowman
Copy link
Contributor Author

Changed to only be the removal of mid for this PR.

@wesleybowman
Copy link
Contributor Author

Moved the style fixes and your request for mapPriority over to PR #45

@wesleybowman wesleybowman changed the title Make journal.py PEP8 compliant and remove mid Remove mid from journal.py Mar 13, 2017
@wesleybowman
Copy link
Contributor Author

@keszybz rebased on master to fix conflicts

@keszybz
Copy link
Member

keszybz commented Mar 14, 2017

The idea was that you can set MESSAGE_ID either on the handler (in which case it lands in _extras and is added to all messages through that handler), or on each individual message. With your patch, setting it on the message is not possible any more.

The issue with current code is that if both are specified, we get an error, because MESSAGE_ID would be specified twice. So this should be fixed, but I think the ability to specify MESSAGE_ID on the message should be retained. If both are present, the one from the message should have higher priority, and the one from the handler should be ignored.

@wesleybowman
Copy link
Contributor Author

If I am understanding correctly, setting it on each individual message is still possible.

Is this an example of setting it on the individual message:
log.warning("Message with ID", extra={'MESSAGE_ID': mid})

and this sets a field for the entire handler:
JournalHandler(SYSLOG_IDENTIFIER='my-cool-app')

If these assumptions are what you are referring to, then this patch will still allow for this.

@keszybz
Copy link
Member

keszybz commented Mar 19, 2017

Ah, I pushed the wrong branch and github closed the PR. I'll submit a replacement PR.

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

Labels

None yet

2 participants