[CXX-1029] Split logging configuration control from instance initialization Created: 12/Sep/16  Updated: 17/Feb/23

Status: Backlog
Project: C++ Driver
Component/s: API, Implementation
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: David Golden Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Easier debugging with standardized logging

 Description   

Currently, mongocxx::instance configures logging on construction. That means that logging can only be safely configured once per application.

There may be cases where turning logging on only temporarily is desirable (e.g. to debug certain sections of code). By binding logging to the lifetime of libmongoc initialization/cleanup, we prevent users from modifying the global logging callback.

We should split logging out of mongocxx::instance and use that only for libmongoc initialization/cleanup. Setting the global logger should be a method on that class.

We could also allow someone to get a copy of the current global logging function and use a guard object to temporarily replace it for a particular scope.



 Comments   
Comment by Andrew Morrow (Inactive) [ 18/Sep/16 ]

I think it might be better to just make it possible to obtain a reference to the configured logger in the instance. The application can then, if needed, downcast to the known dynamic type and interact with it as needed. I do, however, think that we should probably add a mongocxx::instance::options type and make the instance constructor consume that, rather than the logger, directly. That would give us a placeholder for other future instance configuration options.

Generated at Wed Feb 07 22:01:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.