added support for paste loggers

This commit is contained in:
roberto@oneiric64
2012-02-06 16:29:04 +01:00
parent f1b415df2f
commit 594f67c6d7
3 changed files with 26 additions and 0 deletions
+19
View File
@@ -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();
+6
View File
@@ -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},
+1
View File
@@ -126,6 +126,7 @@ struct uwsgi_python {
char *wsgi_config;
char *file_config;
char *paste;
int paste_logger;
char *eval;
char *web3;