Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-5189

Better logging capabilities for loadable modules

XMLWordPrintable

      Steps to reproduce:

      1. Imagine you are a loadable module developer.
      2. Imagine your module does some complex logic. You want to log a few messages to make decisions made by your module visible and help your users to troubleshoot problems. Obviously, you don't want to log these messages every time code of your module is executed.

      Available solutions:

      1. (Ab)use zabbix_log().
        Pros Cons
        No need to implement module-specific logging mechanism. Zabbix does not encourage use of internal Zabbix functions in modules.
        Zabbix synchronizes writes from different processes. Potential API and ABI compatibility issues.
        Log messages have the same format as Zabbix messages (e.g. time stamp, etc.).
        Module is aware of logging level configured for Zabbix including runtime control.
      2. Write to stdout and stderr (Zabbix redirects them to the log file).
        Pros Cons
        Simple as printf(). Need to synchronize writing from different processes.
        Legal. No API or ABI concerns. Need to implement module's own logging level configuration.
          No way to control logging level in runtime (or too difficult to implement it).
          No time stamps (or need to implement them).
      3. Module's own log file.
        Pros&Cons are similar to previous option with even more burden for module developer. Life is simply too short to go this way. And the end user will have two log files to look at and correlate, which isn't good.

      Proposed solution:
      When module provides optional zbx_module_set_log_level() function, Zabbix should tell the module on startup which DebugLevel was set in the configuration file. Whenever user changes logging level using runtime control options, Zabbix will notify module about that. This will allow modules to implement runtime control of logging level even if module uses simplistic printf()-like logging.

      In addition to that Zabbix should set a callback which will be used by the module to put messages into Zabbix log file. This callback should take care of time stamps and log file mutex. Callback should be provided to the module if the latter provides optional zbx_module_set_log_callback() function.

            MVekslers Michael Veksler
            cyclone Glebs Ivanovskis
            Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: