MONGOC_CLIENT_...TURED_LOG_OPTS(3)

πŸ’… mongoc_client_pool_set_structured_log_opts πŸ’…

okay bestie, so this is a libmongoc manpage β€” section 3, the library-calls section β€” and it's all about making your client pool's structured logging behave the way you want it to. let's get into it 🫢


✨ SYNOPSIS ✨

bool
mongoc_client_pool_set_structured_log_opts (mongoc_client_pool_t *pool,
                                            const mongoc_structured_log_opts_t *opts);

🌸 DESCRIPTION 🌸

so basically this call reconfigures your client pool's structured logging subsystem. that's the whole vibe. if you wanna know more, go read Structured Logging (iykyk).

the mongoc_structured_log_opts_t gets copied by the pool β€” like, the pool takes a lil photocopy and keeps it β€” so you can safely destroy your copy once this API call finishes. no cap, you're free. πŸ¦‹

⚠️ but heads up: the application is responsible for making sure any user_data referenced by opts stays valid for the entire lifetime of the pool. the pool does not babysit that for you, bestie. keep it alive. πŸ’€

by default, the mongoc_client_pool_t comes with log options captured from the environment during mongoc_client_pool_new(). wanna see the list of supported options? that lives in mongoc_structured_log_opts_new(). go peek. πŸ‘€

and if you ever wanna just… turn the whole structured logging subsystem off? you can do that:

  • pass NULL as opts, or
  • equivalently, pass NULL as the mongoc_structured_log_func_t in mongoc_structured_log_opts_set_handler().

either way, logging said bye. πŸ‘‹


πŸŽ€ PARAMETERS πŸŽ€

  • pool β€” a mongoc_client_pool_t. your pool. your girl. 🏊
  • opts β€” a mongoc_structured_log_opts_t that you allocated with mongoc_structured_log_opts_new(), or NULL if you're tryna disable structured logging entirely. ✨

⭐ RETURNS ⭐

returns true when you used it correctly. slay. πŸ‘‘

but if you call it multiple times per pool, or after the first client is initialized? it returns false and logs a warning. not me getting caught doing that πŸ™ˆ β€” don't be that girl.


🧚 THREAD SAFETY 🧚

okay this is the important one:

  • this function can only be called once on a pool, and it must be called before the first call to mongoc_client_pool_pop(). periodt. no second chances. πŸ”₯
  • thread safety inside the handler? that's the application's responsibility, bestie β€” not the library's problem πŸ’…
  • handlers may be invoked concurrently by multiple pool users. so like… expect the chaos. 🌈

πŸ’– SEE ALSO πŸ’–

  • Structured Logging

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


and that's the whole page, bestie β€” no notes. this was libmongoc version 2.5.6, dated Oct 09, and honestly it ate. go forth and log structured-ly πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from