README 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. This is a placeholder package for logging messages of various modules
  2. in the form of python scripts. This package is expected to be installed
  3. somewhere like <top-install-dir>/python3.x/site-packages/isc/log_messages
  4. and each message script is expected to be imported as
  5. "isc.log_messages.some_module_messages".
  6. We also need to allow in-source test code to get access to the message
  7. scripts in the same manner. That's why the package is stored in the
  8. directory that shares the same trailing part as the install directory,
  9. i.e., isc/log_messages.
  10. Furthermore, we need to support a build mode using a separate build
  11. tree (such as in the case with 'make distcheck'). In that case if an
  12. application (via a test script) imports "isc.log_messages.xxx", it
  13. would try to import the module under the source tree, where the
  14. generated message script doesn't exist. So, in the source directory
  15. (i.e., here) we provide dummy scripts that subsequently import the
  16. same name of module under the "work" sub-package. The caller
  17. application is assumed to have <top_builddir>/src/lib/python/isc/log_messages
  18. in its module search path (this is done by including
  19. $(COMMON_PYTHON_PATH) in the PYTHONPATH environment variable),
  20. which ensures the right directory is chosen.
  21. A python module or program that defines its own log messages needs to
  22. make sure that the setup described above is implemented. It's a
  23. complicated process, but can generally be done by following a common
  24. pattern:
  25. 1. Create the dummy script (see above) for the module and update
  26. Makefile.am in this directory accordingly. See (and use)
  27. a helper shell script named gen-forwarder.sh.
  28. 2. Update Makefil.am of the module that defines the log message. The
  29. following are a sample snippet for Makefile.am for a module named
  30. "mymodule" (which is supposed to be generated from a file
  31. "mymodule_messages.mes"). In many cases it should work simply by
  32. replacing 'mymodule' with the actual module name.
  33. ==================== begin Makefile.am additions ===================
  34. nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/mymodule_messages.py
  35. pylogmessagedir = $(pyexecdir)/isc/log_messages/
  36. CLEANFILES = $(PYTHON_LOGMSGPKG_DIR)/work/mymodule_messages.py
  37. CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/mymodule_messages.pyc
  38. EXTRA_DIST = mymodule_messages.mes
  39. $(PYTHON_LOGMSGPKG_DIR)/work/mymodule_messages.py : mymodule_messages.mes
  40. $(top_builddir)/src/lib/log/compiler/message \
  41. -d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/mymodule_messages.mes
  42. # This rule ensures mymodule_messages.py is (re)generated as a result of
  43. # 'make'. If there's no other appropriate target, specify
  44. # mymodule_messages.py in BUILT_SOURCES.
  45. mymodule: <other source files> $(PYTHON_LOGMSGPKG_DIR)/work/mymodule_messages.py
  46. ===================== end Makefile.am additions ====================
  47. Notes:
  48. - "nodist_" prefix is important. Without this, 'make distcheck' tries
  49. to make _messages.py before actually starting the main build, which
  50. would fail because the message compiler isn't built yet.
  51. - "pylogmessage" is a prefix for python scripts that define log
  52. messages and are expected to be installed in the common isc/log_messages
  53. directory. It's intentionally named differently from the common
  54. "python" prefix (as in python_PYTHON), because the latter may be
  55. used for other scripts in the same Makefile.am file.
  56. - $(PYTHON_LOGMSGPKG_DIR) should be set to point to this directory (or
  57. the corresponding build directory if it's different) by the
  58. configure script.