Skip to content

CDRIVER-3904 improve documentation regarding when to call mongoc_log_set_handler #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2021
Merged

Conversation

fgalan
Copy link
Contributor

@fgalan fgalan commented Feb 16, 2021

PR as discussed at #736 (comment)

Any feedback is welcome, including .rst syntax, documentation style in the Mongo C driver repository, or even text wording (English is not my native language ;)

@@ -1,3 +1,5 @@
Initialize the MongoDB C Driver by calling :symbol:`mongoc_init` exactly once at the beginning of your program. It is responsible for initializing global state such as process counters, SSL, and threading primitives.

Exception to this is `mongoc_log_set_handler`, which should be called before `mongoc_init()` or some log traces would not use your log handling function. See logging document for details.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See logging document for details

I'm not sure how to link documents in .rst files. Could you provide an example, please?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. See the links in the webpage for aggregate opts here, specifically collation. The text file for it is in aggregate-opts.txt in this same directory.

Linking the logging header would be similar to the header link for Setting Collation Order. In other words,

  1. create an anchor to the header in src/libmongoc/doc/logging.rst (since one doesn't exist). For example,
.. _custom_log_handlers: // <- add anchor

  Custom Log Handlers
 -------------------

  1. Now you can link to that header from this text file. For example,
 :ref:`Custom Log Handler<custom_log_handlers>`

If you'd like to test this locally you can follow the steps here for building the documentation. Afterwards, the HTML files will be in /build/src/libmongoc/doc/html.

Copy link
Contributor

@bazile-clyde bazile-clyde left a comment

Choose a reason for hiding this comment

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

Looks great! I added an answer for "how to link..." question and one small nit.

@@ -1,3 +1,5 @@
Initialize the MongoDB C Driver by calling :symbol:`mongoc_init` exactly once at the beginning of your program. It is responsible for initializing global state such as process counters, SSL, and threading primitives.

Exception to this is `mongoc_log_set_handler`, which should be called before `mongoc_init()` or some log traces would not use your log handling function. See logging document for details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. See the links in the webpage for aggregate opts here, specifically collation. The text file for it is in aggregate-opts.txt in this same directory.

Linking the logging header would be similar to the header link for Setting Collation Order. In other words,

  1. create an anchor to the header in src/libmongoc/doc/logging.rst (since one doesn't exist). For example,
.. _custom_log_handlers: // <- add anchor

  Custom Log Handlers
 -------------------

  1. Now you can link to that header from this text file. For example,
 :ref:`Custom Log Handler<custom_log_handlers>`

If you'd like to test this locally you can follow the steps here for building the documentation. Afterwards, the HTML files will be in /build/src/libmongoc/doc/html.

@@ -100,6 +100,9 @@ For example, you could register a custom handler to suppress messages at INFO le
return 0;
}

Note that in the example above `mongoc_log_set_handler()` is called before ``mongoc_init()``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Here mongoc_log_set_handler() needs two backquote keys around it for monospaced fonts to work.

@fgalan
Copy link
Contributor Author

fgalan commented Feb 22, 2021

Looks great! I added an answer for "how to link..." question and one small nit.

Thank you very much for your feedback and detailed explanation.

I have fixed the PR, hoping now could be merged.

Copy link
Contributor

@bazile-clyde bazile-clyde left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for your contribution. You should see your changes added after our next patch release.

@bazile-clyde bazile-clyde merged commit 43f5997 into mongodb:master Feb 22, 2021
@fgalan fgalan deleted the CDRIVER-3904 branch February 22, 2021 15:36
kevinAlbs pushed a commit that referenced this pull request Apr 8, 2021
chardan pushed a commit to chardan/mongo-c-driver that referenced this pull request Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants