diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index b0099281..868ca219 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -655,6 +655,25 @@ PyObject *uwsgi_paste_loader(void *arg1) { PyObject *paste_arg, *paste_app; uwsgi_log( "Loading paste environment: %s\n", paste); + + if (up.paste_logger) { + PyObject *paste_logger_dict = get_uwsgi_pydict("paste.script.util.logging_config"); + if (paste_logger_dict) { + PyObject *paste_logger_fileConfig = PyDict_GetItemString(paste_logger_dict, "fileConfig"); + if (paste_logger_fileConfig) { + PyObject *paste_logger_arg = PyTuple_New(1); + if (!paste_logger_arg) { + PyErr_Print(); + exit(UWSGI_FAILED_APP_CODE); + } + PyTuple_SetItem(paste_logger_arg, 0, PyString_FromString(paste)); + if (python_call(paste_logger_fileConfig, paste_logger_arg, 0, NULL)) { + PyErr_Print(); + } + } + } + } + paste_module = PyImport_ImportModule("paste.deploy"); if (!paste_module) { PyErr_Print(); diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 9bd96586..4f25d172 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -45,6 +45,10 @@ void uwsgi_opt_ini_paste(char *opt, char *value, void *foobar) { else { up.paste = uwsgi_concat2("config:", value); } + + if (!strcmp("ini-paste-logged", opt)) { + up.paste_logger = 1; + } } #endif @@ -88,6 +92,7 @@ struct uwsgi_option uwsgi_python_options[] = { {"optimize", required_argument, 'O', "set python optimization level", uwsgi_opt_set_int, &up.optimize, 0}, {"paste", required_argument, 0, "load a paste.deploy config file", uwsgi_opt_set_str, &up.paste, 0}, + {"paste-logger", required_argument, 0, "enable paste fileConfig logger", uwsgi_opt_true, &up.paste_logger, 0}, {"web3", required_argument, 0, "load a web3 app", uwsgi_opt_set_str, &up.web3, 0}, @@ -95,6 +100,7 @@ struct uwsgi_option uwsgi_python_options[] = { {"wsgi-lite", required_argument, 0, "load a wsgi-lite app", uwsgi_opt_set_str, &up.wsgi_lite, 0}, #ifdef UWSGI_INI {"ini-paste", required_argument, 0, "load a paste.deploy config file containing uwsgi section", uwsgi_opt_ini_paste, NULL, UWSGI_OPT_IMMEDIATE}, + {"ini-paste-logged", required_argument, 0, "load a paste.deploy config file containing uwsgi section (load loggers too)", uwsgi_opt_ini_paste, NULL, UWSGI_OPT_IMMEDIATE}, #endif {"catch-exceptions", no_argument, 0, "report exception has http output (discouraged)", uwsgi_opt_true, &up.catch_exceptions, 0}, {"ignore-script-name", no_argument, 0, "ignore SCRIPT_NAME", uwsgi_opt_true, &up.ignore_script_name, 0}, diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index 01964405..06d14458 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -126,6 +126,7 @@ struct uwsgi_python { char *wsgi_config; char *file_config; char *paste; + int paste_logger; char *eval; char *web3;