hgomez 01/03/27 13:58:26 Modified: src/native/mod_jk/common jk_util.c jk_util.h Log: Add time stamp support in mod_jk.log Revision Changes Path 1.5 +39 -5 jakarta-tomcat/src/native/mod_jk/common/jk_util.c Index: jk_util.c =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_util.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- jk_util.c 2001/02/05 23:22:04 1.4 +++ jk_util.c 2001/03/27 21:58:26 1.5 @@ -55,8 +55,9 @@ /*************************************************************************** * Description: Utility functions (mainly configuration) * + * Author: Henri Gomez <[EMAIL PROTECTED]> * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.4 $ * + * Version: $Revision: 1.5 $ * ***************************************************************************/ @@ -86,6 +87,7 @@ #define DEFAULT_WORKER JK_AJP12_WORKER_NAME #define WORKER_LIST_PROPERTY_NAME ("worker.list") #define DEFAULT_LB_FACTOR (1.0) +#define LOG_FORMAT ("log_format") #define HUGE_BUFFER_SIZE (8*1024) #define LOG_LINE_SIZE (1024) @@ -95,6 +97,27 @@ }; typedef struct file_logger file_logger_t; +/* + * define the log format, we're using by default the one from error.log + * + * [Mon Mar 26 19:44:48 2001] [jk_uri_worker_map.c (155)]: Into jk_uri_worker_map_t::uri_worker_map_alloc + * log format used by apache in error.log + */ +#ifndef JK_TIME_FORMAT +#define JK_TIME_FORMAT "[%a %b %d %H:%M:%S %Y] " +#endif + +char * jk_log_fmt = JK_TIME_FORMAT; + +static void set_time_str(char * str, int len) +{ + time_t t = time(NULL); + struct tm *tms; + + tms = localtime(&t); + strftime(str, len, jk_log_fmt, tms); +} + static int JK_METHOD log_to_file(jk_logger_t *l, int level, const char *what) @@ -211,17 +234,23 @@ if(f != file) { f++; } - + #ifdef WIN32 - used = _snprintf(buf, HUGE_BUFFER_SIZE, "[%s (%d)]: ", f, line); + set_time_str(buf, HUGE_BUFFER_SIZE); + used = strlen(buf); + used += _snprintf(&buf[used], HUGE_BUFFER_SIZE, " [%s (%d)]: ", f, line); #elif defined(NETWARE) // until we get a snprintf function buf = (char *) malloc(HUGE_BUFFER_SIZE); if (NULL == buf) return -1; - used = sprintf(buf, "[%s (%d)]: ", f, line); + set_time_str(buf, HUGE_BUFFER_SIZE); + used = strlen(buf); + used += sprintf(&buf[used], " [%s (%d)]: ", f, line); #else - used = snprintf(buf, HUGE_BUFFER_SIZE, "[%s (%d)]: ", f, line); + set_time_str(buf, HUGE_BUFFER_SIZE); + used = strlen(buf); + used += snprintf(&buf[used], HUGE_BUFFER_SIZE, " [%s (%d)]: ", f, line); #endif if(used < 0) { return 0; /* [V] not sure what to return... */ @@ -363,6 +392,11 @@ } return JK_FALSE; +} + +void jk_set_log_format(char * logformat) +{ + jk_log_fmt = (logformat) ? logformat : JK_TIME_FORMAT; } double jk_get_lb_factor(jk_map_t *m, 1.3 +3 -1 jakarta-tomcat/src/native/mod_jk/common/jk_util.h Index: jk_util.h =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/common/jk_util.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_util.h 2000/11/10 18:48:50 1.2 +++ jk_util.h 2001/03/27 21:58:26 1.3 @@ -56,7 +56,7 @@ /*************************************************************************** * Description: Various utility functions * * Author: Gal Shachor <[EMAIL PROTECTED]> * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #ifndef _JK_UTIL_H #define _JK_UTIL_H @@ -106,6 +106,8 @@ int jk_get_worker_cache_size(jk_map_t *m, const char *wname, int def); + +void jk_set_log_format(char *logformat); int jk_get_worker_list(jk_map_t *m, char ***list,