upscli_upslog_set_debug_level - Man Page

manipulate the possibly separate (identified via cookie) copies of the `nut_debug_level` and sub-process tag variables in the `libupsclient` build

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

On some platforms, libupsclient builds tend to get a built-in copy of the internal code from NUT libcommon library, so for NUT client programs using both libraries as dynamically-linked shared code, the nut_debug_level setting is backed by independent variables in active memory, and upsdebugx() calls suffer if the library’s copy is never changed from zero​.

It can get even more confusing with libnutprivate-common being a shared dynamically loaded library instance behind both the program and libupsclient, hence the cookies: direct NUT-common code consumers like NUT in-tree clients can use their nut_common_cookie() value to pass into methods here​. Third-party clients may safely pass NULL​.

These methods allow to set or retrieve the value of nut_debug_level setting known by the libupsclient library, regardless of build mode​.

The most likely use (at least in NUT programs) is to call upscli_set_debug_level(nut_debug_level); after changing the original variable​. 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 is up to the code base and NUT style guide practices to assign certain levels to some classes of messages​.

If 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 (keep and report the original setting)​.

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

Note

In WIN32 builds also enforces line-buffering for stdout and stderr streams​.

Return Value

There is no return value for the setter​.

The getter returns the current value of the internal variable​.

See Also

upscli_init(3), upscli_report_build_details(3)

Referenced By

The man pages upscli_upslog_cookie(3), upscli_upslog_get_debug_level(3), upscli_upslog_getproctag(3), upscli_upslog_setprocname(3), upscli_upslog_setproctag(3) and upscli_upslog_start_sync(3) are aliases of upscli_upslog_set_debug_level(3).

08/25/2026 Network UPS Tools 2.8.5 NUT Manual