[SERVER-45783] Add styleguide section in logv2/README.md Created: 27/Jan/20  Updated: 29/Oct/23  Resolved: 04/Feb/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.3.4

Type: Task Priority: Major - P3
Reporter: Henrik Edin Assignee: Henrik Edin
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Dev Tools 2020-02-10
Participants:

 Description   

From Bruce:

For example, maybe something like:

  • "msg" fields (the simple variety) should be pithy noun phrase or sentence describing what is being reported. Initial capital, ending with period .
  • attributes should be a small number of camel-case words succinctly describing the relationship of the attribute to what is being reported in a way that's understandable to someone with a reasonable knowledge of mongod behavior as viewed externally. These would be similar to C++ identifiers, except that unlike C++ identifiers they shouldn't depend on surrounding code context to understand. Depending on "msg" content to understand is ok. Maybe method names in an interface would be a better comparison than variable names?
  • Simple fixed string messages with no additional information needed should be contained in the "msg" field with no attributes. (This is prompted be a counter-example I saw in a log file that looked something like "msg": "{message}", "attr": {"message": "actual message for real now"}. I felt my eyes beginning to bleed. )


 Comments   
Comment by Githook User [ 03/Feb/20 ]

Author:

{'username': 'henrikedin', 'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com'}

Message: SERVER-45783 Add style guide section to logv2/README.md
Branch: master
https://github.com/mongodb/mongo/commit/7739d3935096e3ec158fba279715f16619989d6f

Comment by Henrik Edin [ 27/Jan/20 ]

I think we should keep the attr field even if it contains just an empty object to minimize any impact for parsers.

Comment by Bruce Lucas (Inactive) [ 27/Jan/20 ]

Yes, those look good to me, thanks.

A couple nits:

  • I wonder if we want the terminating period. It doesn't seem to add anything.
  • Should we consider omitting attr in the output if it's empty? That might e.g. make the initial messages in the log file, like the startup warnings that we want the user to see, slightly clearer. OTOH I don't know what impact that might have on automated processors.
Comment by Andy Schwerin [ 27/Jan/20 ]

Potential examples:

{ t: "2020-01-22T00:00:00.000Z", ..., id: 12345, msg: "Replica set state transition on this node.", attr: { oldState: "SECONARY", newState: "PRIMARY" } }
 
{ t: "2020-01-22T00:00:00.000Z", ..., id: 12345, msg: "Transition to PRIMARY complete.", attr: {} }
 
{ t: "2020-01-22T00:00:00.000Z", ..., id: 12345, msg: "Slow query.", attr: { ..., durationMillis: 1000 } }

 

bruce.lucas@mongodb.com, do these look like what you had in mind?

Generated at Thu Feb 08 05:09:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.