XN_C_API void xnLogWriteBinaryData(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, XnUChar* pBinData, XnUInt32 nDataSize, const XnChar* csFormat, ...) { if (!xnLogIsEnabled(csLogMask, nSeverity)) return; // first write preceding message: va_list args; va_start(args, csFormat); xnLogWriteImplV(csLogMask, nSeverity, csFile, nLine, csFormat, args); va_end(args); // now write binary data (in lines of 16 bytes) XnChar csLine[256]; XnUInt32 pos = 0; for (XnUInt32 i = 0; i < nDataSize; ++i) { if ((i % 16) == 0) // first byte in line { // start a new line pos = sprintf(csLine, "%6u: ", i); } pos += sprintf(csLine + pos, "%02x ", pBinData[i]); if ((i % 16) == 15 || (i == nDataSize-1)) // last byte in line { xnLogWriteImpl(csLogMask, nSeverity, csFile, nLine, "%s", csLine); } } }
XN_C_API void xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...) { if (!xnLogIsEnabled(csLogMask, nSeverity)) return; if (g_xnLoggerData.m_bWriteToFile) { va_list args; va_start(args, csFormat); const XnUInt32 nMaxMessageSize = 1024; XnChar csMessage[nMaxMessageSize+1]; XnUInt32 nChars; xnOSStrFormatV(csMessage, nMaxMessageSize, &nChars, csFormat, args); va_end(args); xnOSWriteFile(g_xnLoggerData.m_fLogFile, csMessage, nChars); } if (g_xnLoggerData.m_bWriteToConsole) { va_list args; va_start(args, csFormat); vprintf(csFormat, args); va_end(args); } }
void xnLogConfigurationChanged() { // if new configuration requires a log file, and we don't have one opened if (g_xnLoggerData.m_nLogFilteringType != XN_LOG_WRITE_NONE && g_xnLoggerData.m_bWriteToFile && g_xnLoggerData.m_fLogFile == XN_INVALID_FILE_HANDLE) { XN_PROCESS_ID nProcID = 0; xnOSGetCurrentProcessID(&nProcID); XnChar strFileName[XN_FILE_MAX_PATH]; sprintf(strFileName, "%s%s_%u.log", g_xnLoggerData.m_csLogDir, g_xnLoggerData.m_csTime, nProcID); XnStatus nRetVal = xnLogCreateFile(strFileName, &g_xnLoggerData.m_fLogFile); if (nRetVal != XN_STATUS_OK) { // we don't have much to do if files can't be open. Logs will not be written to file printf("Couldn't create log file %s! Logs will not be written (error: %s)\n", strFileName, xnGetStatusString(nRetVal)); g_xnLoggerData.m_fLogFile = XN_INVALID_FILE_HANDLE; g_xnLoggerData.m_bWriteToFile = FALSE; } } if (!g_xnLoggerData.m_bBannerPrinted && xnLogIsEnabled(XN_MASK_LOG, XN_LOG_INFO)) { xnLogInfo(XN_MASK_LOG, "OpenNI version is %s", XN_VERSION_STRING); g_xnLoggerData.m_bBannerPrinted = TRUE; } if (g_xnLoggerData.m_fLogFile != XN_INVALID_FILE_HANDLE) { XnChar csMasks[XN_LOG_MASKS_STRING_LEN]; xnLogGetMasksString(csMasks); xnLogWriteImpl(XN_MASK_LOG, XN_LOG_INFO, __FILE__, __LINE__, "Log system initialized. Console: %d, File: %d, Severity: %s, Masks: %s", g_xnLoggerData.m_bWriteToConsole, g_xnLoggerData.m_bWriteToFile, xnLogGetSeverityString(g_xnLoggerData.m_nFilterSeverity), csMasks); } }
XN_C_API void xnLogWrite(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFile, XnUInt32 nLine, const XnChar* csFormat, ...) { if (!xnLogIsEnabled(csLogMask, nSeverity)) return; // write message va_list args; va_start(args, csFormat); xnLogWriteImplV(csLogMask, nSeverity, csFile, nLine, csFormat, args); va_end(args); }
XN_C_API void xnLogWriteNoEntry(const XnChar* csLogMask, XnLogSeverity nSeverity, const XnChar* csFormat, ...) { if (!xnLogIsEnabled(csLogMask, nSeverity)) return; va_list args; va_start(args, csFormat); const XnUInt32 nMaxMessageSize = 1024; XnChar csMessage[nMaxMessageSize+1]; XnUInt32 nChars; xnOSStrFormatV(csMessage, nMaxMessageSize, &nChars, csFormat, args); va_end(args); for (XnLogWritersList::ConstIterator it = g_logData.m_writers.begin(); it != g_logData.m_writers.end(); ++it) { const XnLogWriter* pWriter = *it; pWriter->WriteUnformatted(csMessage, pWriter->pCookie); } }
void XnSensorFPS::Mark(XnFPSData* pFPS, const XnChar* csName, XnUInt32 nFrameID, XnUInt64 nTS) { if (!xnLogIsEnabled(XN_MASK_SENSOR_FPS, XN_LOG_VERBOSE)) return; XnUInt64 nNow; xnOSGetHighResTimeStamp(&nNow); xnFPSMarkFrame(pFPS, nNow); xnDumpWriteString(m_FramesDump, "%llu,%s,%u,%llu\n", nNow, csName, nFrameID, nTS); // get current time in seconds nNow /= 1000000; if (nNow != m_nLastPrint) { m_nLastPrint = nNow; xnLogVerbose(XN_MASK_SENSOR_FPS, "[FPS] InputFrames - I: %5.2f, D: %5.2f, OutputFrames - I: %5.2f, D: %5.2f", xnFPSCalc(&m_InputImage), xnFPSCalc(&m_InputDepth), xnFPSCalc(&m_OutputImage), xnFPSCalc(&m_OutputDepth)); } }