ddcutil icon indicating copy to clipboard operation
ddcutil copied to clipboard

Allow libddcutil users to provide custom logging facilities instead of syslog

Open LordMZTE opened this issue 6 months ago • 2 comments

It appears that libddcutil will always log to syslog (unless logging is disabled entirely). In order to be able to keep log output in one place for applications that use libddcutil, it would be beneficial if it were possible to provide a callback function pointer that libddcutil would invoke, passing log level, message (maybe as format string and args?) as well as a userdata pointer for an application to be able to handle logging.

LordMZTE avatar Aug 29 '25 22:08 LordMZTE

Interesting enhancement request. Unfortunately, it's non-trivial. The logging and tracing facilities have accreted over the years, (see the output of ddcutil --hh | grep -E "log|trace"). Passing a format string with args would require rewriting all calls that ultimately result in a line in the system log, whatever the path.

I'm curious to know what your application is that uses libddcutil and would benefit from this enhancement.

You may describe the enhancment in the Discussions section. Perhaps it has wider utility than I imagine.

rockowitz avatar Aug 30 '25 06:08 rockowitz

My application is quite trivial actually, it's just a small script I have in my dotfiles that will set the brightness of all monitors via both DDC and sysfs and decided to port it over to libddcutil in favor of the command to improve performance (which is quite noticable). The log output thing is just a minor nitpick here, but since many libraries offer this sort of API, I thought it might be worth mentioning. (code)

LordMZTE avatar Aug 30 '25 10:08 LordMZTE