]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add libpython global option to enable verbose logs
authorNick Porter <nick@portercomputing.co.uk>
Fri, 11 Apr 2025 16:09:01 +0000 (17:09 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 11 Apr 2025 16:34:04 +0000 (17:34 +0100)
For deep debugging of Python behaviour

raddb/global.d/python
src/modules/rlm_python/rlm_python.c

index 5bc6df7953e1dc3d9e82aa1eb6b0d0969607e0d9..4eca12850eb6aef572b57d2434f214197005cc64 100644 (file)
@@ -14,4 +14,9 @@ python {
        #  path components will be prepended to the the default search path.
        #
 #      path_include_default = "yes"
+
+       #  verbose::
+       #
+       #  If "yes", enable libpython verbose logging messages.
+#      verbose = no
 }
index 7400b0fc6e74fe673dfc0d3e3d037ed926b22431..2d86f0dbf767c6b2d01184249a743ef481f2a525 100644 (file)
@@ -78,6 +78,7 @@ typedef struct {
 typedef struct {
        char const      *path;                  //!< Path to search for python files in.
        bool            path_include_default;   //!< Include the default python path in `path`
+       bool            verbose;                //!< Enable libpython verbose logging
 } libpython_global_config_t;
 
 /** Tracks a python module inst/thread state pair
@@ -103,6 +104,7 @@ static libpython_global_config_t libpython_global_config = {
 static conf_parser_t const python_global_config[] = {
        { FR_CONF_OFFSET("path", libpython_global_config_t, path) },
        { FR_CONF_OFFSET("path_include_default", libpython_global_config_t, path_include_default) },
+       { FR_CONF_OFFSET("verbose", libpython_global_config_t, verbose) },
        CONF_PARSER_TERMINATOR
 };
 
@@ -1159,6 +1161,8 @@ static int libpython_init(void)
 
        config.install_signal_handlers = 0;     /* Don't override signal handlers - noop on subs calls */
 
+       if (libpython_global_config.verbose) config.verbose = 1;        /* Enable libpython logging*/
+
        LSAN_DISABLE(status = Py_InitializeFromConfig(&config));
        if (PyStatus_Exception(status)) goto fail;