void WriteStopLogString( FILE *traceOut ) { #if defined(_WIN32)// && defined(_DEBUG) if(IsDebugOutEnabled()) outputDebugString( NULL, c_STOP_LOG_FILE_STR, getpid(), GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str()); #endif // записываем строчку открытия log файла #ifndef __unix__ fwprintf( traceOut, c_STOP_LOG_FILE_STR, #else KLSTD_USES_CONVERSION; fprintf( traceOut, KLSTD_W2CA(c_STOP_LOG_FILE_STR), #endif #ifdef N_PLAT_NLM 0, #else getpid(), #endif GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str() ); fflush( traceOut ); }
/** * @brief Generate simple xml report header. */ void DirCmpReport::GenerateXmlHeader() { WriteString(_T("")); // @todo xml declaration WriteString(_T("<WinMergeDiffReport version=\"1\">\n")); WriteString(Fmt(_T("<left>%s</left>\n"), m_rootPaths.GetLeft().c_str())); WriteString(Fmt(_T("<right>%s</right>\n"), m_rootPaths.GetRight().c_str())); WriteString(Fmt(_T("<time>%s</time>\n"), GetCurrentTimeString().c_str())); // Add column headers const CString rowEl = _T("column_name"); WriteString(BeginEl(rowEl)); for (int currCol = 0; currCol < m_nColumns; currCol++) { TCHAR columnName[160]; // Assuming max col header will never be > 160 LVCOLUMN lvc; lvc.mask = LVCF_TEXT; lvc.pszText = &columnName[0]; lvc.cchTextMax = countof(columnName); const CString colEl = m_colRegKeys[currCol]; if (m_pList->GetColumn(currCol, &lvc)) { WriteString(BeginEl(colEl)); WriteString(lvc.pszText); WriteString(EndEl(colEl)); } } WriteString(EndEl(rowEl) + _T("\n")); }
/** * @brief Generate body portion of simple html report header (w/o body tag). */ void DirCmpReport::GenerateHTMLHeaderBodyPortion() { WriteString(_T("<h2>")); WriteString(m_sTitle); WriteString(_T("</h2>\n<p>")); WriteString(GetCurrentTimeString().c_str()); WriteString(_T("</p>\n")); WriteString(_T("<table border=\"1\">\n<tr>\n")); for (int currCol = 0; currCol < m_nColumns; currCol++) { TCHAR columnName[160]; // Assuming max col header will never be > 160 LVCOLUMN lvc; lvc.mask = LVCF_TEXT; lvc.pszText = &columnName[0]; lvc.cchTextMax = countof(columnName); if (m_pList->GetColumn(currCol, &lvc)) { WriteString(_T("<th>")); WriteString(lvc.pszText); WriteString(_T("</th>")); } } WriteString(_T("</tr>\n")); }
void WriteStartLogString( FILE *traceOut ) { #if defined(_WIN32)// && defined(_DEBUG) if(IsDebugOutEnabled()) outputDebugString( NULL, c_START_LOG_FILE_STR, getpid(), GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str()); #endif // записываем строчку открытия log файла #ifndef __unix__ fwprintf( traceOut, c_START_LOG_FILE_STR, #else KLSTD_USES_CONVERSION; fprintf( traceOut,KLSTD_W2CA(c_START_LOG_FILE_STR), #endif #ifdef N_PLAT_NLM 0, #else getpid(), #endif GetCurrentTimeString( TF_PRINT_MILLISECONDS ).c_str() ); std::wstring wstrOsName, wstrOsVer; GetSystemVersionInfo(wstrOsName, wstrOsVer); fprintf(traceOut, "System:\t %ls\nVersion:\t%ls\n\n", wstrOsName.c_str(), wstrOsVer.c_str()); fflush( traceOut ); }
/** * @brief Generate header-data for report. */ void DirCmpReport::GenerateHeader() { WriteString(m_sTitle); WriteString(_T("\n")); WriteString(GetCurrentTimeString().c_str()); WriteString(_T("\n")); for (int currCol = 0; currCol < m_nColumns; currCol++) { TCHAR columnName[160]; // Assuming max col header will never be > 160 LVCOLUMN lvc; lvc.mask = LVCF_TEXT; lvc.pszText = &columnName[0]; lvc.cchTextMax = countof(columnName); if (m_pList->GetColumn(currCol, &lvc)) WriteString(lvc.pszText); // Add col-separator, but not after last column if (currCol < m_nColumns - 1) WriteString(m_sSeparator); } }
//!\brief Общая функция трассировачного вывода void TraceCommon( int traceLevel, const wchar_t *module, const wchar_t *format, va_list args ) { if ( klTraceInfo==NULL ) return; TraceAutoUnlock unlocker; if ( !(klTraceInfo->traceFlags & TF_NOT_SYNCHRONIZE) ) unlocker.Init( klTraceCricSec ); FILE *out = klTraceInfo->traceOut; int level = klTraceInfo->traceLevel; if ( klTraceInfo->IsModulesFiltered( traceLevel ) ) { TraceModuleDesc *fDesc = klTraceInfo->GetTracedModuleDesc( module ); if ( fDesc!=NULL ) out = fDesc->traceOut, level = fDesc->traceLevel; else return; } if ( klTraceInfo->IsThreadsFiltered() ) { TraceThreadDesc *fDesc = klTraceInfo->GetTracedThreadDesc( KLGetCurrentThreadId() ); if ( fDesc!=NULL ) out = fDesc->traceOut, level = fDesc->traceLevel; else return; } if ( traceLevel <= level && traceLevel!=0 ) { if ( klTraceInfo->traceFlags==0 ){ vfwprintf( out, format, args ); } else { #if defined (__unix) //|| defined (N_PLAT_NLM) std::wstringstream s_out; if ( klTraceInfo->traceFlags & TF_PRINT_DATETIME ) s_out << GetCurrentTimeString( klTraceInfo->traceFlags ).data() << " "; #else char dateTimeString[128]; wchar_t additionalInfoStr[256]; wchar_t moduleFormatedString[256]; additionalInfoStr[0]=0; dateTimeString[0]=0; #endif #if defined (_WIN32) || defined (N_PLAT_NLM) if ( klTraceInfo->traceFlags & TF_PRINT_DATETIME ) { strcat( dateTimeString, GetCurrentTimeString( klTraceInfo->traceFlags ).c_str() ); } #endif if ( klTraceInfo->traceFlags & TF_PRINT_THREAD_ID ) { #if defined(_WIN32) || defined(N_PLAT_NLM) swprintf( additionalInfoStr, L" %08X", KLGetCurrentThreadId() ); #else s_out << std::hex << std::setiosflags(std::ios_base::right) << std::setfill('0') << std::setw(8) << KLGetCurrentThreadId(); #endif } if ( klTraceInfo->traceFlags & TF_PRINT_MODULE ) { #if defined(_WIN32) || defined(N_PLAT_NLM) swprintf( moduleFormatedString, L" %6ls", module ); wcscat( additionalInfoStr, moduleFormatedString ); #else s_out << ' ' << module; #endif } #if defined(__unix) std::wofstream fs( fileno(out) ); fs << s_out.str() << " "; _safe_printer( fs, format, args ); #else fwprintf( out, L"%hs %ls: ", dateTimeString, additionalInfoStr ); vfwprintf( out, format, args ); #endif #if defined(_WIN32)// && defined(_DEBUG) if(IsDebugOutEnabled()) { wchar_t additionalBuff[512]; KLSTD_SWPRINTF(additionalBuff, KLSTD_COUNTOF(additionalBuff), L"%hs %ls: ", dateTimeString, additionalInfoStr ); additionalBuff[KLSTD_COUNTOF(additionalBuff)-1]=0; outputDebugStringV(module, additionalBuff, args); outputDebugStringV(module, format, args); }; #endif } fflush( out ); } #ifdef N_PLAT_NLM else ThreadSwitch(); #endif }