Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace zabbix_log() macro provided by Zabbix #142

Open
wants to merge 1 commit into
base: master
from

Conversation

@i-ky
Copy link
Contributor

commented May 1, 2019

Our own macro will ensure log level check across all versions of Zabbix.

Some background story. zabbix_log() has always been a wrapper macro for __zbx_zabbix_log() function. It takes the severity level of a log message, format string and variable number of arguments. Depending on the severity of the log message and logging level currently in action, log message may or may not end up in the actual Zabbix log. In older versions of Zabbix, log level check was performed by the __zbx_zabbix_log() function, but after ZBX-10889 the situation has changed. Depending on how Zabbix was compiled, the check will be performed by the __zbx_zabbix_log() function like before or by the zabbix_log() macro itself. What this effectively means is that loadable module compiled with older zabbix_log() macro definition and loaded into newer Zabbix binary may end up with no log level check whatsoever when calling __zbx_zabbix_log() function.

In order to provide a guarantee that module can be compiled with any version of Zabbix headers and then used with any other version of Zabbix, I decided to implement an independent zabbix_log() macro which will check log level on its own. Again, runtime linking is used to get access to current log level settings, because API has changed in ZBX-10889. Before runtime linking is complete zabbix_log() cannot be used, therefore I've replaced it with printf() and fprintf(stderr, ...). Zabbix redirects stdout and stderr to the log file anyway.

For a test, I've compiled the module with good old 3.2 and latest trunk and then successfully loaded it into oldish 3.4 and trunk in all possible combinations. However, I'm not using this module or PostgreSQL in my everyday life, so some more in-depth testing may be required.

Hopefully, this will be enough to craft a single binary package compatible with all more or less current versions of Zabbix (despite binary compatibility not being officially supported).

…h will ensure log level check across all versions of Zabbix
@biertie

This comment has been minimized.

Copy link

commented Sep 12, 2019

Hello,

Can someone check and approve this patch? :-)
We are waiting for it. Sadly enough, not enough C experience here.

Bert

@i-ky

This comment has been minimized.

Copy link
Contributor Author

commented Sep 14, 2019

@biertie, you don't need to be an experienced C programmer. If you are using this module and can test this branch with various versions of Zabbix, you can provide quite useful feedback.

@OrangeDog

This comment has been minimized.

Copy link

commented Oct 11, 2019

@cavaliercoder can this be merged? And then ideally can you sort out being able to release it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.