Better Log facilities

Kevin Hoogheem wrote this addition to the log manager.

HTlog.h

/* Defines for Loging
** heres the standard way of login looks like.
**	Format: <HOST> - - <DATE> <METHOD> <URI> <RESULT> <CONTENT_LENTGH>
*/
#define LOG_STANDARD 1
/**	Format: <HOST> - - <DATE> <METHOD>*/
#define LOG_HDM 2
/**	Format: <HOST> - - <DATE> <URI>*/
#define LOG_HDU 3
/**	Format: <HOST> - - <DATE> <METHOD> <URI>*/
#define LOG_HDMU 4
/**	Format: <HOST> - - <DATE> <METHOD> <URI> <RESULT>*/
#define LOG_HDMUR 5
/**	Format: <URI>*/
#define LOG_URI 6

HTlog.c

/*	Add entry to the log file
**	-------------------------
**	Format: <HOST> - - <DATE> <METHOD> <URI> <RESULT> <CONTENT_LENTGH>
**	which is almost equivalent to Common Logformat. Permissions on UNIX
**	are modified by umask.
**
**	Returns YES if OK, NO on error
**
**	BUG: No result code is produced :-( Should be taken from HTError.c
*/
PUBLIC BOOL HTLog_add (HTRequest * request, int status, int method)
{
    if (HTLogFile) {
	time_t now = time(NULL);
	HTParentAnchor *anchor = HTRequest_anchor(request);
	char * uri = HTAnchor_address((HTAnchor *) anchor);
	if (WWWTRACE) TTYPrint(TDEST, "Log......... Writing log\n");
	switch(method){
	  case LOG_STANDARD:
	    fprintf(HTLogFile, "localhost - - [%s] %s %s %d %ld\n",
		  HTDateTimeStr(&now, HTloglocal),
		  HTMethod_name(HTRequest_method(request)),
		  uri,
		  status,
		  HTAnchor_length(anchor));
	    FREE(uri);
	    break;
	  case LOG_HDM:
	    fprintf(HTLogFile, "localhost - - [%s] %s\n",
		  HTDateTimeStr(&now, HTloglocal),
		  HTMethod_name(HTRequest_method(request));
		break;
	  case LOG_HDU:
	    fprintf(HTLogFile, "localhost - - [%s] %s\n",
		  HTDateTimeStr(&now, HTloglocal),
		  uri);
	    FREE(uri);
	    break;
	  case LOG_HDMU:
	    fprintf(HTLogFile, "localhost - - [%s] %s %s\n",
		  HTDateTimeStr(&now, HTloglocal),
		  HTMethod_name(HTRequest_method(request)),
		  uri);
	    FREE(uri);
	    break;
	  case LOG_HDMUR:
	    fprintf(HTLogFile, "localhost - - [%s] %s %s %d\n",
		  HTDateTimeStr(&now, HTloglocal),
		  HTMethod_name(HTRequest_method(request)),
		  uri,
		  status);
	    FREE(uri);
	    break;
	  case LOG_URI:
	    fprintf(HTLogFile, "%s\n",uri);
	    FREE(uri);
	    break;
	  default:
	    fprintf(HTLogFile, "[%s] - - Loging Method Not defined\n",
		  HTDateTimeStr(&now, HTloglocal));
	    break;
	}
	return (fflush(HTLogFile)!=EOF);       /* Actually update it on disk */
    }
    return NO;
}


Henrik Frystyk, Feb 1996