Added logger spec parser for CLI args
Questo commit è contenuto in:
parent
c83d63c8f2
commit
686e6ecf2e
3 ha cambiato i file con 38 aggiunte e 8 eliminazioni
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
#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 { \
|
||||
{"config", required_argument, 0, 'C'},\
|
||||
|
|
@ -77,7 +77,8 @@
|
|||
{"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- FILT a number (in decimal or hexadicimal 0xXX) indicating wich\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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -122,13 +122,10 @@ PyObject* import_entrypoint()
|
|||
if(!entry_module)
|
||||
{
|
||||
//TODO syslog python error / traceback
|
||||
pyfcgi_log( LOG_CRIT,
|
||||
"Unable to import python file '%s'",
|
||||
pyfcgi_log(LOG_CRIT, "Unable to import python file '%s'",
|
||||
PyFCGI_conf.py_entrymod);
|
||||
pyfcgi_log( LOG_INFO,
|
||||
"%s", getcwd(NULL, 256));
|
||||
//pyfcgi_log( LOG_INFO, "%s", getcwd(NULL, 256));
|
||||
log_expt(LOG_ERR);
|
||||
sleep(1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -139,9 +136,10 @@ PyObject* import_entrypoint()
|
|||
if(!entry_fun)
|
||||
{
|
||||
//TODO syslog python error / traceback
|
||||
pyfcgi_log( LOG_CRIT,
|
||||
pyfcgi_log(LOG_CRIT,
|
||||
"Unable to import object '%s' from '%s'",
|
||||
PyFCGI_conf.py_entryfun, PyFCGI_conf.py_entrymod);
|
||||
log_expt(LOG_ERR);
|
||||
return NULL;
|
||||
}
|
||||
if(!PyCallable_Check(entry_fun))
|
||||
|
|
|
|||
Caricamento…
Aggiungi tabella
Aggiungi collegamento
Crea riferimento in una nuova segnalazione