Changeset 6617
- Timestamp:
- Nov 11, 2016 3:50:35 AM (7 years ago)
- Location:
- pymolproxy/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pymolproxy/trunk/Makefile.in
r6605 r6617 1 WANT_DEBUG = #yes 1 2 2 3 TARGETS = pymolproxy … … 8 9 -DSVN_VERSION=\"$(SVN_VERSION)\" \ 9 10 -DSTATSDIR=\"$(STATSDIR)\" \ 10 -DLOGDIR=\"$(LOGDIR)\" 11 -DLOGDIR=\"$(LOGDIR)\" 11 12 EXTRA_CFLAGS = -Wall 12 13 INCLUDES = $(TCL_INC_SPEC) -I$(srcdir) … … 31 32 STATSDIR = @STATSDIR@ 32 33 LOGDIR = @LOGDIR@ 34 35 ifdef WANT_DEBUG 36 DEFINES += -DWANT_DEBUG 37 endif 33 38 34 39 .PHONY: all install clean distclean -
pymolproxy/trunk/pymolproxy.c
r6614 r6617 99 99 #define TRUE 1 100 100 101 static int debug = FALSE;102 static FILE *f record;101 static FILE *frecord = NULL; 102 static FILE *flog = NULL; 103 103 static int recording = FALSE; 104 104 static int pymolIsAlive = TRUE; 105 105 static int statsFile = -1; 106 106 107 #define WANT_DEBUG 0 108 #define READ_DEBUG 0 109 #define WRITE_DEBUG 0 110 #define EXEC_DEBUG 0 107 #define READ_DEBUG 1 108 #define WRITE_DEBUG 1 109 #define EXEC_DEBUG 1 111 110 #define LOG_PYMOL_STDERR 0 112 111 … … 213 212 } PymolProxy; 214 213 215 #if WANT_DEBUG216 #define DEBUG(...) if (debug)PrintToLog(__VA_ARGS__)214 #ifdef WANT_DEBUG 215 #define DEBUG(...) PrintToLog(__VA_ARGS__) 217 216 #else 218 217 #define DEBUG(...) … … 224 223 #define INFO(...) SysLog(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) 225 224 225 #if 0 226 226 static const char *syslogLevels[] = { 227 227 "emergency", /* System is unusable */ … … 234 234 "debug", /* Debug-level messages */ 235 235 }; 236 237 #if WANT_DEBUG 236 #endif 237 238 #ifdef WANT_DEBUG 238 239 static void 239 240 PrintToLog(const char *format, ...) … … 241 242 va_list args; 242 243 244 if (flog == NULL) return; 245 243 246 va_start(args, format); 244 fprintf( stderr, "pymolproxy: ");245 vfprintf( stderr, format, args);247 fprintf(flog, "pymolproxy: "); 248 vfprintf(flog, format, args); 246 249 va_end(args); 247 fprintf( stderr, "\n");248 fflush( stderr);250 fprintf(flog, "\n"); 251 fflush(flog); 249 252 } 250 253 #endif … … 266 269 s++; 267 270 } 268 length = snprintf(message, MSG_LEN, "pymolproxy (%d) %s: %s:%d ", 269 getpid(), syslogLevels[priority], s, lineNum); 271 length = snprintf(message, MSG_LEN, "%s:%d: ", s, lineNum); 270 272 length += vsnprintf(message + length, MSG_LEN - length, fmt, lst); 271 273 message[MSG_LEN] = '\0'; 272 274 va_end(lst); 273 275 274 if ( debug) {276 if (priority == LOG_DEBUG) { 275 277 DEBUG("%s", message); 276 278 } else { … … 283 285 { 284 286 va_list args; 287 288 if (frecord == NULL) return; 285 289 286 290 va_start(args, format); … … 2280 2284 status = GetLine(&p->client, &numBytes, &line); 2281 2285 if (status != BUFFER_OK) { 2282 ERROR("can't read client stdout (numBytes=%d, status=%d): %s", 2283 numBytes, status, strerror(errno)); 2286 if (status == BUFFER_EOF) { 2287 DEBUG("Exiting server on EOF from client"); 2288 } else { 2289 ERROR("Exiting server, failed to read from client (numBytes=%d, status=%d): %s", 2290 numBytes, status, strerror(errno)); 2291 } 2284 2292 goto done; 2285 2293 } … … 2439 2447 ERROR("Short write on version string", strerror(errno)); 2440 2448 } 2449 2450 flog = stderr; 2451 openlog("pymolproxy", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); 2441 2452 DEBUG("Starting pymolproxy"); 2442 2453
Note: See TracChangeset
for help on using the changeset viewer.