UPSCLI_UPSLOG_SET_DE(3)

πŸ“¦
version 2.8.5 Β· 4 versions
, in arch rolling

πŸ’… UPSCLI_UPSLOG_SET_DE(3) β€” the NUT Manual, section 3, bestie

okay so this is a libupsclient page from the NUT Manual and it's genuinely one of those "the vibes are complicated but I promise it slaps once you get it" situations πŸŽ€

✨ NAME ✨

Meet the whole friend group πŸ’–:

  • upscli_upslog_set_debug_level
  • upscli_upslog_get_debug_level
  • upscli_upslog_cookie
  • upscli_upslog_setprocname
  • upscli_upslog_setproctag
  • upscli_upslog_getproctag
  • upscli_upslog_start_sync

collectively? they manipulate the possibly separate (identified via cookie) copies of the nut_debug_level and sub-process tag variables living inside the libupsclient build. yes, copies. plural. we'll get there 🫢


🌸 SYNOPSIS 🌸

#include <upsclient.h>

const void *upscli_upslog_cookie(void);

void upscli_set_debug_level(int, const void *cookie);
int  upscli_get_debug_level(void);

void upscli_setprocname(const char *full_procname, const void *cookie);
void upscli_setproctag(const char *tag, const void *cookie);
const char *upscli_getproctag(void);

struct timeval *upscli_upslog_start_sync(struct timeval *tv, const void *cookie);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the lore πŸ‘‘. On some platforms, libupsclient builds tend to get a built-in copy of the internal code from the NUT libcommon library. Which means β€” for NUT client programs that use both libraries as dynamically-linked shared code β€” the nut_debug_level setting is backed by independent variables in active memory. and like… upsdebugx() calls suffer if the library's copy is never changed from zero. πŸ’€ yes really. your debug level is living two separate lives.

and it gets even more confusing when libnutprivate-common is a shared dynamically loaded library instance sitting behind both the program and libupsclient. hence the cookies πŸͺ β€” that's literally the whole reason they exist. direct NUT-common code consumers, like NUT in-tree clients, can use their nut_common_cookie() value and pass it into the methods here. third-party clients may safely pass NULL. no cap.

so these methods let you set or retrieve the value of the nut_debug_level setting that the libupsclient library knows about β€” regardless of build mode. main character energy fr fr ✨

the most likely use (at least in NUT programs) is to call upscli_set_debug_level(nut_debug_level); after changing the original variable. and just so you know the levels: values of the debugging level are zero to disable debug, may be negative for a few special cases, and generally are positive numbers to cut off the more verbose logging attempts. otherwise it's up to the code base and NUT style guide practices to assign certain levels to some classes of messages. iykyk 🌈

then there's this one: if the internal upslog_start value is not yet set, we can set it with upscli_upslog_start_sync() from *tv (or current time if tv==NULL), otherwise the method is no-op β€” it keeps and reports the original setting. lowkey elegant πŸ’…

it returns the pointer to the currently set value, so it can be propagated or used in difftime() computations. handy!

Note 🫢 In WIN32 builds this also enforces line-buffering for stdout and stderr streams.

⭐ RETURN VALUE ⭐

there is no return value for the setter. it's giving "i do the thing, i don't need applause" πŸ™ˆ

the getter returns the current value of the internal variable.


πŸŽ€ SEE ALSO πŸŽ€


and that's the page, bestie β€” go forth and debug πŸ’œ

Network UPS Tools 2.8.5 Β· dated 06/21/2026 Β· mwah, stan the NUT Manual for me πŸ“πŸ§š

πŸ“¦ where this page comes from
  • arch rolling: nut 2.8.5-2 Β· GPL-2.0-or-later AND GPL-3.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms