[SERVER-54596] 1-arg shouldLog violates One Definition Rule Created: 17/Feb/21  Updated: 29/Oct/23  Resolved: 18/Mar/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-52604 Log from anywhere (normalize MONGO_LO... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Security 2021-03-22
Participants:
Story Points: 2

 Description   

[subtask of SERVER-52604]

mongo::shouldLog(component, severity) is fine.

mongo::shouldLog(severity) fills in the default component by referring to a variable in the anonymous namespace. So a program will have multiple mongo::shouldLog(severity) definitions, all referring to completely different component variables. This is a violation of the One Definition Rule.

Can be easily fixed, just remove the 1-arg shouldLog function. Replace all callers (7 or so) with shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, severity)

https://github.com/mongodb/mongo/commit/955af4ef6fa94b76a24faa810435181b5ee3e140

 



 Comments   
Comment by Githook User [ 18/Mar/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-54596 remove 1-arg shouldLog function (an ODR violation)
Branch: master
https://github.com/mongodb/mongo/commit/fad9de4ece9f5399acc804f206e40621930be5af

Comment by Githook User [ 18/Mar/21 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@gmail.com', 'username': 'BillyDonahue'}

Message: SERVER-54596 remove 1-arg shouldLog function (an ODR violation)
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/736aba10c00744baec2d19db5dd3874d3d0ee650

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