MONGOC_STRUCTU...EVELS_FROM_ENV(3)

πŸ’… MONGOC_STRUCTU...EVELS_FROM_ENV(3) ✨

okay so bestie, this is a libmongoc page β€” yes the title up top is literally truncated with ... in the middle, that's not me being messy, that's just how the header came through 😭 we keep it, we love it, we move on.


🫢 SYNOPSIS 🫢

bool
mongoc_structured_log_opts_set_max_levels_from_env (mongoc_structured_log_opts_t *opts);

so what does it do? it sets any max log levels that the environment variables are asking for, in this exact order:

  • MONGODB_LOG_ALL β€” this one's for all components, and it goes first πŸ’–
  • then the per-component ones, in this order: MONGODB_LOG_COMMAND, MONGODB_LOG_CONNECTION, MONGODB_LOG_TOPOLOGY, and MONGODB_LOG_SERVER_SELECTION 🌈

it expects each value to be something mongoc_structured_log_get_named_level() actually recognizes β€” like, the value has to be a name it knows, no cap. if parsing goes wrong you might get a warning message, and that warning gets delivered via unstructured logging (yes, the old-school channel, iconic of it).

any component level that has no valid environment variable setting just gets left unmodified β€” no touching, no drama, it stays exactly how it was πŸŽ€


🌸 the automatic part (this is the tea) 🌸

this whole thing happens automatically when mongoc_structured_log_opts_new() establishes defaults. literally on its own, no extra call from you 🫢

and then β€” any subsequent programmatic modifications you make to the mongoc_structured_log_opts_t will override the environment variable settings. so like, env vars set the vibe first, then you come in and change it. you win. periodt πŸ’…

but bestie, what if you want the opposite?? what if you want the environment variables to override your programmatic settings instead? valid. main character energy. in that case, call mongoc_structured_log_opts_set_max_levels_from_env() after you call mongoc_structured_log_opts_set_max_level_for_component() and mongoc_structured_log_opts_set_max_level_for_all_components(). that processes the environment a second time πŸ”₯ which lets it override your customized defaults. slay.


⭐ RETURNS ⭐

  • returns true on success ✨
  • if warnings are encountered in the environment, it returns false and may log additional information to the unstructured logging facility πŸ“
⚠️ note that, by design, these errors are by default non-fatal. so like, don't panic. but also know that when mongoc_structured_log_opts_new() internally calls this function, it ignores the return value entirely πŸ™ˆ β€” so a false in that path lowkey goes nowhere.

πŸ‘€ SEE ALSO πŸ‘€

  • Structured Logging

πŸ¦‹ AUTHOR πŸ¦‹

MongoDB, Inc

2009-present, MongoDB, Inc.


and that's the page, bestie πŸŽ€ version 2.5.6, dated Oct 09, 202 β€” yeah the year got ate by the header on the way out, she's giving truncated, we still stan; anyway, MongoDB, Inc. wrote this and holds the copyright from 2009 to present, libmongoc forever πŸ‘‘ 🫢

πŸ“¦ where this page comes from