Skip to content
Snippets Groups Projects
Commit 84c33445 authored by rswindell's avatar rswindell
Browse files

HTTP standard log file logging is now enabled with the sbbs.ini [Web]

HTTP_LOGGING Options bit. The default base filename is now
"data/logs/http-" (using the correctly configured data_dir) and can be over-
ridden with the "HttpLogFile" key (the "LogFile" key is preserved for use with
sbbsctrl-Win32).
The http_logging_thread() is only started if http logging is enabled.
parent ec021c0e
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,7 @@ static ini_bitdesc_t web_options[] = {
{ WEB_OPT_DEBUG_TX ,"DEBUG_TX" },
{ WEB_OPT_VIRTUAL_HOSTS ,"VIRTUAL_HOSTS" },
{ WEB_OPT_NO_CGI ,"NO_CGI" },
{ WEB_OPT_HTTP_LOGGING ,"HTTP_LOGGING" },
/* shared bits */
{ BBS_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" },
......
......@@ -435,7 +435,7 @@ void sbbs_read_ini(
SAFECOPY(web->cgi_dir
,iniReadString(fp,section,"CGIDirectory",WEB_DEFAULT_CGI_DIR,value));
SAFECOPY(web->logfile_base
,iniReadString(fp,section,"LogFile",WEB_DEFAULT_LOGFILE,value));
,iniReadString(fp,section,"HttpLogFile",nulstr,value));
iniFreeStringList(web->index_file_name);
web->index_file_name
......@@ -460,7 +460,7 @@ void sbbs_read_ini(
=iniReadBitField(fp,section,strLogMask,log_mask_bits,global->log_mask);
web->options
=iniReadBitField(fp,section,strOptions,web_options
,BBS_OPT_NO_HOST_LOOKUP);
,BBS_OPT_NO_HOST_LOOKUP | WEB_OPT_HTTP_LOGGING);
}
}
......
......@@ -2555,15 +2555,12 @@ void http_session_thread(void* arg)
while((redirp==NULL || session.req.send_location >= MOVED_TEMP)
&& !session.finished && server_socket!=INVALID_SOCKET) {
session.req.send_location=NO_LOCATION;
if(startup->logfile_base[0])
session.req.ld=malloc(sizeof(struct log_data));
else
session.req.ld=NULL;
if(session.req.ld==NULL) {
if(startup->logfile_base[0])
session.req.ld=NULL;
if(startup->options&WEB_OPT_HTTP_LOGGING) {
if((session.req.ld=(struct log_data*)malloc(sizeof(struct log_data)))==NULL)
lprintf(LOG_ERR,"Cannot allocate memory for log data!");
}
else {
if(session.req.ld!=NULL) {
memset(session.req.ld,0,sizeof(struct log_data));
session.req.ld->hostname=strdup(session.host_name);
}
......@@ -2666,15 +2663,15 @@ const char* DLLCALL web_ver(void)
void http_logging_thread(void* arg)
{
char base[128];
char filename[128+15];
char newfilename[128+15];
char base[MAX_PATH+1];
char filename[MAX_PATH+1];
char newfilename[MAX_PATH+1];
FILE* logfile=NULL;
SAFECOPY(base,arg);
if(!base[0])
return;
FREE_AND_NULL(arg);
SAFEPRINTF(base,"%slogs/http-",scfg.data_dir);
filename[0]=0;
newfilename[0]=0;
......@@ -2710,7 +2707,7 @@ void http_logging_thread(void* arg)
if(logfile!=NULL) {
sprintf(sizestr,"%d",ld->size);
strftime(timestr,sizeof(timestr),"%d/%b/%G:%H:%M:%S %z",&ld->completed);
while(lock(fileno(logfile),0,1)) {
while(lock(fileno(logfile),0,1) && !terminate_server) {
SLEEP(10);
}
fprintf(logfile,"%s %s %s [%s] \"%s\" %d %s \"%s\" \"%s\"\n"
......@@ -2823,14 +2820,16 @@ void DLLCALL web_server(void* arg)
terminate_server=FALSE;
/********************/
/* Start log thread */
/********************/
sem_init(&log_sem,0,0);
pthread_mutex_init(&log_mutex,NULL);
log_list=malloc(sizeof(link_list_t));
listInit(log_list,LINK_LIST_NEVER_FREE);
_beginthread(http_logging_thread, 0, strdup(startup->logfile_base));
if(startup->options&WEB_OPT_HTTP_LOGGING) {
/********************/
/* Start log thread */
/********************/
sem_init(&log_sem,0,0);
pthread_mutex_init(&log_mutex,NULL);
log_list=malloc(sizeof(link_list_t));
listInit(log_list,LINK_LIST_NEVER_FREE);
_beginthread(http_logging_thread, 0, startup->logfile_base);
}
do {
......
......@@ -91,11 +91,11 @@ typedef struct {
#define WEB_OPT_DEBUG_TX (1<<1) /* Log all transmitted responses */
#define WEB_OPT_VIRTUAL_HOSTS (1<<4) /* Use virutal host html subdirs */
#define WEB_OPT_NO_CGI (1<<5) /* Disable CGI support */
#define WEB_OPT_HTTP_LOGGING (1<<6) /* Create/write-to HttpLogFile */
#define WEB_DEFAULT_ROOT_DIR "../html"
#define WEB_DEFAULT_ERROR_DIR "error"
#define WEB_DEFAULT_CGI_DIR "cgi-bin"
#define WEB_DEFAULT_LOGFILE "../data/httpd-"
#ifdef DLLEXPORT
#undef DLLEXPORT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment