Added logger spec parser for CLI args
This commit is contained in:
parent
c83d63c8f2
commit
686e6ecf2e
3 changed files with 38 additions and 8 deletions
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
#define PYFCGI_NAME "spawn-fcgi [OPTIONS] -- pyfcgi"
|
#define PYFCGI_NAME "spawn-fcgi [OPTIONS] -- pyfcgi"
|
||||||
|
|
||||||
#define PYFCGI_SHORT_OPT "Ce:E:w:W:m:l:Svh"
|
#define PYFCGI_SHORT_OPT "Ce:E:w:W:m:L:Svh"
|
||||||
|
|
||||||
#define PYFCGI_LONG_OPT { \
|
#define PYFCGI_LONG_OPT { \
|
||||||
{"config", required_argument, 0, 'C'},\
|
{"config", required_argument, 0, 'C'},\
|
||||||
|
|
@ -77,7 +77,8 @@
|
||||||
{"Display this help and exit", NULL},\
|
{"Display this help and exit", NULL},\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PYFCGI_HELP_TEXT "Logger specification format 'LOGFILE[;FILT][;FMT]' with :\n\
|
#define PYFCGI_HELP_TEXT "\n\
|
||||||
|
Logger specification format 'LOGFILE[;FILT][;FMT]' with :\n\
|
||||||
\t- LOGFILE the log file name\n\
|
\t- LOGFILE the log file name\n\
|
||||||
\t- FILT a number (in decimal or hexadicimal 0xXX) indicating wich\n\
|
\t- FILT a number (in decimal or hexadicimal 0xXX) indicating wich\n\
|
||||||
\t facility/level to log\n\
|
\t facility/level to log\n\
|
||||||
|
|
|
||||||
31
src/conf.c
31
src/conf.c
|
|
@ -156,6 +156,37 @@ int check_entrypoint_import()
|
||||||
|
|
||||||
int parse_optlog(const char* logspec)
|
int parse_optlog(const char* logspec)
|
||||||
{
|
{
|
||||||
|
char *filename, *filter, *fmt;
|
||||||
|
int filt;
|
||||||
|
|
||||||
|
filename = strdup(logspec); /**@todo check error */
|
||||||
|
filter = filename;
|
||||||
|
while(*filter && *filter != ';') { filter++; }
|
||||||
|
if(*filter)
|
||||||
|
{
|
||||||
|
*filter = '\0';
|
||||||
|
filter++;
|
||||||
|
}
|
||||||
|
fmt = filter;
|
||||||
|
while(*fmt && *fmt != ';') { fmt++; }
|
||||||
|
if(*fmt)
|
||||||
|
{
|
||||||
|
*fmt = '\0';
|
||||||
|
fmt++;
|
||||||
|
}
|
||||||
|
if(!strlen(filter))
|
||||||
|
{
|
||||||
|
filt = 0xFF;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filt = strtol(filter, NULL, !strncmp(filter, "0x", 2)?16:10);
|
||||||
|
}
|
||||||
|
fmt = strlen(fmt)?fmt:NULL;
|
||||||
|
if(pyfcgi_logger_add(filename, filt, filt, fmt))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,13 +122,10 @@ PyObject* import_entrypoint()
|
||||||
if(!entry_module)
|
if(!entry_module)
|
||||||
{
|
{
|
||||||
//TODO syslog python error / traceback
|
//TODO syslog python error / traceback
|
||||||
pyfcgi_log( LOG_CRIT,
|
pyfcgi_log(LOG_CRIT, "Unable to import python file '%s'",
|
||||||
"Unable to import python file '%s'",
|
|
||||||
PyFCGI_conf.py_entrymod);
|
PyFCGI_conf.py_entrymod);
|
||||||
pyfcgi_log( LOG_INFO,
|
//pyfcgi_log( LOG_INFO, "%s", getcwd(NULL, 256));
|
||||||
"%s", getcwd(NULL, 256));
|
|
||||||
log_expt(LOG_ERR);
|
log_expt(LOG_ERR);
|
||||||
sleep(1);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,9 +136,10 @@ PyObject* import_entrypoint()
|
||||||
if(!entry_fun)
|
if(!entry_fun)
|
||||||
{
|
{
|
||||||
//TODO syslog python error / traceback
|
//TODO syslog python error / traceback
|
||||||
pyfcgi_log( LOG_CRIT,
|
pyfcgi_log(LOG_CRIT,
|
||||||
"Unable to import object '%s' from '%s'",
|
"Unable to import object '%s' from '%s'",
|
||||||
PyFCGI_conf.py_entryfun, PyFCGI_conf.py_entrymod);
|
PyFCGI_conf.py_entryfun, PyFCGI_conf.py_entrymod);
|
||||||
|
log_expt(LOG_ERR);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(!PyCallable_Check(entry_fun))
|
if(!PyCallable_Check(entry_fun))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue