Changeset 913
- Timestamp:
- 09/11/07 13:23:15 (1 year ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/Makefile.am (modified) (1 diff)
- cherokee/trunk/cherokee/cherokee.h (modified) (1 diff)
- cherokee/trunk/cherokee/macros.h (modified) (1 diff)
- cherokee/trunk/cherokee/server.c (modified) (1 diff)
- cherokee/trunk/cherokee/trace.c (added)
- cherokee/trunk/cherokee/trace.h (added)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (1 diff)
- cherokee/trunk/configure.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r912 r913 1 2007-09-11 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/trace.h, cherokee/trace.c, cherokee/macros.h, 4 cherokee/Makefile.am, cherokee/util.c, cherokee/util.h, 5 cherokee/cherokee.h, cherokee/server.c, configure.in: Tracing 6 facility moved to an independent file. The code has been slightly 7 reworked in order to allow the modification of the modules been 8 traced dynamically. 9 1 10 2007-09-07 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 11 cherokee/trunk/cherokee/Makefile.am
r912 r913 736 736 util.h \ 737 737 util.c \ 738 trace.h \ 739 trace.c \ 738 740 version.h \ 739 741 version.c \ cherokee/trunk/cherokee/cherokee.h
r841 r913 44 44 #include <cherokee/resolv_cache.h> 45 45 #include <cherokee/post.h> 46 #include <cherokee/trace.h> 46 47 47 48 /* Server library cherokee/trunk/cherokee/macros.h
r906 r913 311 311 /* Tracing facility 312 312 */ 313 #define TRACE_ENV "CHEROKEE_TRACE" 314 313 315 #ifdef TRACE_ENABLED 314 # define TRACE_ENV "CHEROKEE_TRACE"315 316 316 # ifdef __GNUC__ 317 # define TRACE(fmt,arg...) cherokee_trace (fmt, __FILE__, __LINE__, __cherokee_func__, ##arg)318 # else 319 # define TRACE(fmt,...) cherokee_trace (fmt, __FILE__, __LINE__, __cherokee_func__, __VA_ARGS__)317 # define TRACE(fmt,arg...) cherokee_trace_do_trace (fmt, __FILE__, __LINE__, __cherokee_func__, ##arg) 318 # else 319 # define TRACE(fmt,...) cherokee_trace_do_trace (fmt, __FILE__, __LINE__, __cherokee_func__, __VA_ARGS__) 320 320 # endif 321 321 #else cherokee/trunk/cherokee/server.c
r906 r913 100 100 ret_t ret; 101 101 CHEROKEE_NEW_STRUCT(n, server); 102 103 cherokee_trace_init (); 102 104 103 105 /* Thread list cherokee/trunk/cherokee/util.c
r900 r913 897 897 898 898 899 900 #ifdef TRACE_ENABLED901 902 void903 cherokee_trace (const char *entry, const char *file, int line, const char *func, const char *fmt, ...)904 {905 static char *env = NULL;906 static cuint_t env_set = 0;907 static cuint_t use_syslog = 0;908 cherokee_boolean_t do_log = false;909 cherokee_buffer_t entries = CHEROKEE_BUF_INIT;910 cherokee_buffer_t output = CHEROKEE_BUF_INIT;911 char *lentry;912 char *lentry_end;913 va_list args;914 char *p;915 916 /* Read the environment variable in the first call917 */918 if (env_set == 0) {919 env = getenv(TRACE_ENV);920 env_set = 1;921 922 if (env != NULL)923 use_syslog = (strstr (env, "syslog") != NULL);924 }925 926 /* Return quickly if there isn't anything to do927 */928 if (env == NULL) {929 return;930 }931 932 cherokee_buffer_add (&entries, entry, strlen(entry));933 934 for (lentry = entries.buf;;) {935 lentry_end = strchr (lentry, ',');936 if (lentry_end) *lentry_end = '\0';937 938 /* Check for 'all'939 */940 p = strstr (env, "all");941 if (p) do_log = true;942 943 /* Check the type944 */945 p = strstr (env, lentry);946 if (p) {947 char *tmp = p + strlen(lentry);948 if ((*tmp == '\0') || (*tmp == ',') || (*tmp == ' '))949 do_log = true;950 }951 952 if (lentry_end == NULL)953 break;954 955 lentry = lentry_end + 1;956 }957 958 if (! do_log) goto out;959 960 /* Print the trace961 */962 cherokee_buffer_add_va (&output, "%18s:%04d (%30s): ", file, line, func);963 964 va_start (args, fmt);965 cherokee_buffer_add_va_list (&output, (char *)fmt, args);966 va_end (args);967 968 if (use_syslog) {969 syslog (LOG_DEBUG, "%s", output.buf);970 } else {971 #ifdef HAVE_FLOCKFILE972 flockfile (stdout);973 #endif974 fprintf (stdout, "%s", output.buf);975 #ifdef HAVE_FUNLOCKFILE976 funlockfile (stdout);977 #endif978 }979 980 out:981 cherokee_buffer_mrproper (&output);982 cherokee_buffer_mrproper (&entries);983 }984 985 #endif986 987 988 989 899 ret_t 990 900 cherokee_short_path (cherokee_buffer_t *path) cherokee/trunk/cherokee/util.h
r862 r913 32 32 #include <cherokee/common.h> 33 33 #include <cherokee/avl.h> 34 #include <cherokee/trace.h> 34 35 35 36 #ifdef HAVE_NETINET_IN_H cherokee/trunk/configure.in
r903 r913 131 131 AC_DEFINE_UNQUOTED(OS_TYPE, "${os_string}", [OS type]) 132 132 133 AM_CONDITIONAL(PLATFORM_WIN32, test x"$os_string" = "xWin32") 134 135 dnl 136 dnl Tracing 137 dnl 133 138 AC_ARG_ENABLE(trace, AC_HELP_STRING([--enable-trace], [Enable trace facility]), 134 139 [enable_trace="$enableval" … … 136 141 ], [enable_trace="no"]) 137 142 143 138 144 dnl 139 145 dnl Dynamic library loading library … … 142 148 AC_DEFINE_UNQUOTED(SO_SUFFIX, "${so_suffix}", [Dynamic loading libraries extension]) 143 149 AC_DEFINE_UNQUOTED(MOD_SUFFIX, "${mod_suffix}", [Dynamic modules extension]) 144 145 dnl146 dnl Platforms147 dnl148 AM_CONDITIONAL(PLATFORM_WIN32, test x"$os_string" = "xWin32")149 150 150 151 dnl