MONGOC_CLIENT...TURED_LOG_OPTS(3)

✨ mongoc_client_set_structured_log_opts ✨

okay bestie so this is a page straight out of libmongoc and it's all about reconfiguring the structured logging on a single client. yes, we're talking logging. and honestly? it's giving main character energy. πŸ’…

🌸 SYNOPSIS 🌸

bool
mongoc_client_set_structured_log_opts (mongoc_client_t *client,
                                       const mongoc_structured_log_opts_t *opts);

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does it actually do? It reconfigures this client's structured logging subsystem. That's it, that's the vibe. If you want the deep lore, go peek at Structured Logging. πŸ‘‘

πŸ’€ important bestie: do NOT call this on clients that are part of a mongoc_client_pool_t. Structured logging for pools has to be configured with mongoc_client_pool_set_structured_log_opts() before the first call to mongoc_client_pool_pop(). no cap, that's a hard rule.

The mongoc_structured_log_opts_t gets copied by the client, so you can safely destroy yours after this API call completes β€” she's got her own copy, she doesn't need yours anymore 🫢. But heads up: you (the application) are responsible for making sure any user_data referenced by opts stays valid for the lifetime of the client. don't go freeing that stuff, okay? πŸ™ˆ

By default, the mongoc_client_t will have log options captured from the environment during mongoc_client_new(). for the full list of supported options, go look at mongoc_structured_log_opts_new(). iykyk 🌈

And you can straight up disable the whole structured logging subsystem β€” just pass NULL as opts, or equivalently pass NULL as the mongoc_structured_log_func_t in mongoc_structured_log_opts_set_handler(). literally two ways to the same slay. ✨

πŸŽ€ PARAMETERS πŸŽ€

  • client β€” a mongoc_client_t. the one and only ✨
  • opts β€” a mongoc_structured_log_opts_t allocated with mongoc_structured_log_opts_new(), or NULL to disable structured logging. pick your fighter πŸ’…

⭐ RETURNS ⭐

Returns true when used correctly. πŸ’– If you call it on a pooled client, it returns false and logs a warning β€” so like, read the room, bestie. 😭

πŸ”₯ SEE ALSO πŸ”₯

Structured Logging

πŸ’œ AUTHOR πŸ’œ

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the whole page, bestie! 🧚 go forth and log responsibly. this masterpiece of documentation is from libmongoc version 2.5.6, dated Oct 09, 2026 β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from