Change to MOZ_LOG output formatting coming: Thread identifiers will include the PID (process id)

Right now MOZ_LOG's default output does not include process identifiers, 
so messages from different processes look misleadingly similar:

[Main Thread]: D/nsBlah Message Message
[Main Thread]: D/nsBlah Message Message

They will soon instead look like:

[4372:Main Thread]: D/nsBlah Message Message
[4452:Main Thread]: D/nsBlah Message Message

If you mainly interact with things through mach, you may be thinking, 
"Hey!  What about those PIDs things get tagged with?":

GECKO(3972) | [Main Thread]: D/nsBlah Message Message
GECKO(3972) | [Main Thread]: D/nsBlah Message Message

AFAICT, mach and/or its helpers are doing a best-effort tagging of the 
stdout/stderr of the spawned parent process.  Since the content 
processes inherit the descriptors of the parent, mach/friends are unable 
to magically figure out the true writer without additional machinery to 
give each content process its own descriptors that are pushed out to 
mach via sendmsg or something else fancy.  So everything gets labeled 
with the parent PID.  It would be cool to have a mechanism so that the 
structured logging output could be properly labeled, but that arguably 
is a different bug.

The change to add the PID is tracked on 
https://bugzilla.mozilla.org/show_bug.cgi?id=1428979 so if you have 
thoughts/proposals/patches, please chime in there.  This change will 
likely land sometime late today or tomorrow otherwise.  This may break 
log parsers that use very specific regexps, although the location was 
chosen to leverage the enclosing "[]" and the one I know about is fine[1].

If you would like to learn more about Gecko logging in general, please 
see 
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Gecko_Logging

If you're wondering why this didn't seem to be a problem for Necko's 
cool about:networking logging as documented at 
https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging 
it's because MOZ_LOG did already have a mechanism for partitioning log 
files by labeled process, see 
https://searchfox.org/mozilla-central/rev/03877052c151a8f062eea177f684a2743cd7b1d5/xpcom/base/Logging.cpp#136

Andrew

1: https://github.com/mayhemer/logan/blob/master/logan-rules.js#L5


0
Andrew
1/10/2018 4:36:32 PM
mozilla.dev.platform 6457 articles. 0 followers. Post Follow

0 Replies
51 Views

Similar Articles

[PageSpeed] 46

Reply: