MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLvDebug

Function CPLvDebug

port/cpl_error.cpp:588–707  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586/************************************************************************/
587
588static void CPLvDebug(const char *pszCategory,
589 CPL_FORMAT_STRING(const char *pszFormat), va_list args)
590{
591 CPLErrorContext *psCtx = CPLGetErrorContext();
592 if (psCtx == nullptr || IS_PREFEFINED_ERROR_CTX(psCtx))
593 return;
594 const char *pszDebug = CPLGetConfigOption("CPL_DEBUG", nullptr);
595
596 /* -------------------------------------------------------------------- */
597 /* Does this message pass our current criteria? */
598 /* -------------------------------------------------------------------- */
599 if (pszDebug == nullptr || EQUAL(pszDebug, "NO") ||
600 EQUAL(pszDebug, "OFF") || EQUAL(pszDebug, "FALSE") ||
601 EQUAL(pszDebug, "0"))
602 {
603 return;
604 }
605
606 if (!EQUAL(pszDebug, "ON") && !EQUAL(pszDebug, "YES") &&
607 !EQUAL(pszDebug, "TRUE") && !EQUAL(pszDebug, "1") &&
608 !EQUAL(pszDebug, ""))
609 {
610 // check if value of CPL_DEBUG contains the category
611 const size_t nLen = strlen(pszCategory);
612
613 size_t i = 0;
614 for (i = 0; pszDebug[i] != '\0'; i++)
615 {
616 if (EQUALN(pszCategory, pszDebug + i, nLen))
617 break;
618 }
619
620 if (pszDebug[i] == '\0')
621 return;
622 }
623
624 /* -------------------------------------------------------------------- */
625 /* Allocate a block for the error. */
626 /* -------------------------------------------------------------------- */
627 const int ERROR_MAX = 25000;
628 char *pszMessage = static_cast<char *>(VSIMalloc(ERROR_MAX));
629 if (pszMessage == nullptr)
630 return;
631
632 /* -------------------------------------------------------------------- */
633 /* Dal -- always log a timestamp as the first part of the line */
634 /* to ensure one is looking at what one should be looking at! */
635 /* -------------------------------------------------------------------- */
636
637 pszMessage[0] = '\0';
638#ifdef TIMESTAMP_DEBUG
639 if (CPLTestBool(CPLGetConfigOption("CPL_TIMESTAMP", "NO")))
640 {
641 static struct CPLTimeVal tvStart;
642 static const auto unused = CPLGettimeofday(&tvStart, nullptr);
643 CPL_IGNORE_RET_VAL(unused);
644 struct CPLTimeVal tv;
645 CPLGettimeofday(&tv, nullptr);

Callers 2

CPLDebugFunction · 0.85
CPLDebugProgressFunction · 0.85

Calls 13

CPLGetErrorContextFunction · 0.85
VSIMallocFunction · 0.85
CPLTestBoolFunction · 0.85
VSICTimeFunction · 0.85
CPLsnprintfFunction · 0.85
CPLsprintfFunction · 0.85
CPLGetProcessMemorySizeFunction · 0.85
CPLvsnprintfFunction · 0.85
ApplyErrorHandlerFunction · 0.85
VSIFreeFunction · 0.85
CPLGettimeofdayFunction · 0.70
CPL_IGNORE_RET_VALFunction · 0.70

Tested by

no test coverage detected