msDebug() ** ** Outputs/logs messages to the MS_ERRORFILE if one is set ** (see msSetErrorFile()) ** */
| 347 | ** |
| 348 | */ |
| 349 | void msDebug( const char * pszFormat, ... ) |
| 350 | { |
| 351 | va_list args; |
| 352 | debugInfoObj *debuginfo = msGetDebugInfoObj(); |
| 353 | |
| 354 | if (debuginfo == NULL || debuginfo->debug_mode == MS_DEBUGMODE_OFF) |
| 355 | return; /* Don't waste time here! */ |
| 356 | |
| 357 | if (debuginfo->fp) |
| 358 | { |
| 359 | /* Writing to a stdio file handle */ |
| 360 | |
| 361 | #if defined(USE_FASTCGI) |
| 362 | /* It seems the FastCGI stuff inserts a timestamp anyways, so */ |
| 363 | /* we might as well skip this one if writing to stderr w/ FastCGI. */ |
| 364 | if (debuginfo->debug_mode != MS_DEBUGMODE_STDERR) |
| 365 | #endif |
| 366 | { |
| 367 | struct mstimeval tv; |
| 368 | time_t t; |
| 369 | msGettimeofday(&tv, NULL); |
| 370 | t = tv.tv_sec; |
| 371 | msIO_fprintf(debuginfo->fp, "[%s].%ld ", |
| 372 | msStringChop(ctime(&t)), (long)tv.tv_usec); |
| 373 | } |
| 374 | |
| 375 | va_start(args, pszFormat); |
| 376 | msIO_vfprintf(debuginfo->fp, pszFormat, args); |
| 377 | va_end(args); |
| 378 | } |
| 379 | #ifdef _WIN32 |
| 380 | else if (debuginfo->debug_mode == MS_DEBUGMODE_WINDOWSDEBUG) |
| 381 | { |
| 382 | /* Writing to Windows Debug Console */ |
| 383 | |
| 384 | char szMessage[MESSAGELENGTH]; |
| 385 | |
| 386 | va_start(args, pszFormat); |
| 387 | vsnprintf( szMessage, MESSAGELENGTH, pszFormat, args ); |
| 388 | va_end(args); |
| 389 | |
| 390 | szMessage[MESSAGELENGTH-1] = '\0'; |
| 391 | OutputDebugStringA(szMessage); |
| 392 | } |
| 393 | #endif |
| 394 | |
| 395 | } |
| 396 |
no test coverage detected