BOOL LOGFILE::Write(const char *pszEntry, ...) { static BOOL bTimestampNextLine = TRUE; if (!m_fp) return FALSE; if (bTimestampNextLine && (m_eTimeStampMode == TSM_EACH_ENTRY)) WriteTimeStamp(); va_list args; va_start(args, pszEntry); int nWritten = vfprintf(m_fp, pszEntry, args); va_end(args); fflush(m_fp); // Don't timestamp next line unless current line ended with a newline bTimestampNextLine = (pszEntry[strlen(pszEntry) - 1] == '\n'); return (nWritten > 0); }
BOOL LOGFILE::Open(const char *pszLogFilePath, LOGFILE_OPEN_MODE eOpenMode, LOGFILE_TIMESTAMP_MODE eTimeStampMode) { char *pszOpenMode; m_eTimeStampMode = eTimeStampMode; if (eOpenMode == OM_OVERWRITE) pszOpenMode = "w"; else pszOpenMode = "a+"; strcpy(m_szPath, pszLogFilePath); m_fp = fopen(pszLogFilePath, pszOpenMode); if (m_fp) { if (m_eTimeStampMode != TSM_NEVER) WriteTimeStamp(); fprintf(m_fp, "Log file open.\r\n"); return TRUE; } return FALSE; }
BOOL LOGFILE::WriteError(const char *pszMsg, DWORD nErrorCode, ...) { if (!m_fp) return FALSE; if (m_eTimeStampMode == TSM_EACH_ENTRY) WriteTimeStamp(); va_list args; va_start(args, nErrorCode); int nWritten = vfprintf(m_fp, pszMsg, args); va_end(args); if (nWritten < 1) return FALSE; afs_status_t nStatus; const char *pszErrorText; int nResult = util_AdminErrorCodeTranslate(nErrorCode, TaLocale_GetLanguage(), &pszErrorText, &nStatus); if (nResult) fprintf(m_fp, ": (0x%lx), %s.\r\n", nErrorCode, pszErrorText); else fprintf(m_fp, ": (0x%lx).\r\n", nErrorCode); fflush(m_fp); return (nWritten > 0); }
static void WriteTxBuffer(const tString *pBuf) { EnableSmClkUser(BT_DEBUG_UART_USER); if (TimeStampEnabled) WriteTimeStamp(); while (*pBuf) WRITE_UART(*pBuf++); /* wait until transmit is done */ while (UCA3STAT & UCBUSY); DisableSmClkUser(BT_DEBUG_UART_USER); }
void AssetManager::CheckForChangedAssets() { // Iterate through all assets for (std::pair<const unsigned, Asset*>& asset : mAssetContainer) { if (asset.second->mName == AssetHandleFee) continue; if (!asset.second->FileID().Valid()) continue; boost::filesystem::path filePath = asset.second->FileID().Filename(); boost::filesystem::path metaPath = filePath; metaPath += MetaExt; // If meta file already created, check time stamp if (boost::filesystem::exists(metaPath)) { // Check time stamp FILETIME writeTime = GetTimeStamp(filePath), metaTime = GetMetaTimeStamp(metaPath); // meta time is earlier than write time, reload asset if (CompareFileTime(&metaTime, &writeTime) < 0) { //UniqueFileID fileid(filePath.string()); GetAsset(filePath.leaf().string()).GetRawAssetPtr()->OnAssetFileChanged(); // Write time stamp to meta file WriteTimeStamp(metaPath, writeTime); } } else { // Write time stamp to meta file FILETIME writeTime = GetTimeStamp(filePath); WriteTimeStamp(metaPath, writeTime); } } }
BOOL LOGFILE::Close() { int nResult = 0; if (m_fp) { if (m_eTimeStampMode != TSM_NEVER) WriteTimeStamp(); fprintf(m_fp, "Closing log file.\r\n"); nResult = fclose(m_fp); if (nResult == 0) m_fp = 0; } return (nResult == 0); }
void CXMLLogWriter::WriteRevisionInfo ( CBufferedOutFile& file , const CRevisionInfoContainer& info , revision_t revision , index_t index ) { static const std::string startText = "<logentry\n revision=\""; static const std::string revisionEndText = "\">\n"; static const std::string startAuthorText = "<author>"; static const std::string endAuthorText = "</author>\n"; static const std::string msgText = "<msg>"; static const std::string endText = "</msg>\n</logentry>\n"; // <logentry> start tag (includes revision) file << startText; file << revision; file << revisionEndText; // write the author, if given const char* author = info.GetAuthor ( index ); if ( *author != 0 ) { file << startAuthorText; file << author; file << endAuthorText; } // add time stamp, if given WriteTimeStamp ( file, info.GetTimeStamp ( index ) ); // list the changed paths, if given WriteChanges ( file, info.GetChangesBegin ( index ), info.GetChangesEnd ( index ) ); // always add the commit message file << msgText; file << info.GetComment ( index ); file << endText; }