void LogHandler( QtMsgType type, const char *msg ) { static QMutex s_mutex; QMutexLocker locker( &s_mutex ); switch( type ) { case QtDebugMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; break; case QtCriticalMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n"; break; case QtWarningMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n"; break; case QtFatalMsg: logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << "\n"; logfile.flush(); /* cout << msg << "\n"; cout.flush();*/ abort(); break; } // std::cout << msg << "\n"; // cout.flush(); logfile.flush(); }
//write the result data to a file void write_result(std::map<std::string, struct allRecord>& result, struct configParam& configPam, std::ofstream& out, std::ofstream& out_detail) { int sum = configPam.qps * configPam.time; std::string func[5] = {"set", "get", "del", "check_set", "check_del"}; std::string head_print[][7] = { {"hash_key_size", "sort_key_size", "value_size", "qps", "sum_data", "client_num"}, {trans(configPam.hashKeySize), trans(configPam.sortKeySize), trans(configPam.valueSize), trans(configPam.qps), trans(sum), trans(configPam.client_num) }, {"function", "success_num", "failure_num", "success_ratio", "avg_time(ms)"}, {"function", "fail_type", "fail_num"}, {"error", "hash_key", "sort_key", "value_get", "rel_value", "fail_type"} }; out << "<table>"; write_to_file(head_print[0], 6, out, "th"); write_to_file(head_print[1], 6, out, "td"); out << std::endl; write_to_file(head_print[2], 5, out, "th"); for(int i=0; i<5; i++) { write_to_file(new std::string[5]{func[i], trans(sum - result[ func[i] ].fail_num), trans(result[ func[i] ].fail_num), trans((double)(sum - result[ func[i] ].fail_num) / sum * 100)+"%", trans(result[ func[i] ].sum_time / sum) }, 5, out, "td"); } bool is_print_head= true; //judge have the error or not for(int i=0; i < 5; i++) { struct allRecord temp = result[ func[i] ]; std::map<std::string, int> rec; for(int j = 0; j < temp.fail_num; j++) { if(is_print_head) { is_print_head = false; write_to_file(head_print[3], 3, out, "th class = 'errorStyle' "); out_detail << "<table>"; write_to_file(head_print[0], 6, out_detail, "th"); write_to_file(head_print[1], 6, out_detail, "td"); write_to_file(head_print[4], 6, out_detail, "th"); } rec[temp.fail_types[j] ]++; write_to_file(new std::string[7]{func[i], temp.hash_keys[j], temp.sort_keys[j], temp.value_gets[j], generateValue(temp.sort_keys[j], configPam.valueSize), temp.fail_types[j]}, 6, out_detail, "td"); } std::map<std::string, int>::iterator it; for(it = rec.begin(); it!=rec.end(); it++) { write_to_file(new std::string[3]{func[i], it->first, trans(it->second)}, 3, out, "td"); } } if(!is_print_head) { out_detail << "</table></br>"; } out << "</table></br>"; out.flush(); out_detail.flush(); }
int GameMain() { WriteStandardPaths(); EnumDirs(); WriteHeader("EnumFiles: kPath_Data"); EnumFiles(kPath_Data); WriteHeader("EnumFiles: kPath_UserSave"); EnumFiles(kPath_UserSave); { ibFile<char> inFile = TestOpenData(); ibFile<char> outFile = TestOpenUser(inFile.Size()); while (!inFile.IsReady()) {} if (!outFile.IsReady()) fout << "Outfile ready check failed!" << std::endl; else { ibMemcpy(outFile.GetData(), inFile.GetData(), outFile.Size()); outFile.WriteFile(); } while (!outFile.IsReady()) {} } fout.flush(); Sleep(1000); fout.close(); return 0; }
void Logger::close(){ if (logger_os.is_open()){ logger_os.flush(); logger_os.close(); logger_messageLevel = logNone; } }
static void WriteOutput(double value) { LOG_INFO("----------------------------------------------------------\n"); LOG_INFO("%d %f %d %d :: %lf", state.logging_type, ycsb::state.update_ratio, ycsb::state.scale_factor, ycsb::state.backend_count, value); auto& storage_manager = storage::StorageManager::GetInstance(); auto& log_manager = logging::LogManager::GetInstance(); // FIXME accumulate fsync count across all frontend loggers auto frontend_logger = log_manager.GetFrontendLogger(0); auto fsync_count = 0; if (frontend_logger != nullptr) { fsync_count = frontend_logger->GetFsyncCount(); } LOG_INFO("fsync count : %d", fsync_count); LOG_INFO("clflush count : %lu", storage_manager.GetClflushCount()); LOG_INFO("msync count : %lu", storage_manager.GetMsyncCount()); out << state.logging_type << " "; out << ycsb::state.update_ratio << " "; out << ycsb::state.scale_factor << " "; out << ycsb::state.backend_count << " "; out << value << "\n"; out.flush(); }
void DestinationTable::record_end () { out << record_separator; if (flush) out.flush (); }
/// Prints a formatted message to stdout, optionally color coded void Error::msg(MessageType messageType, const char *format, int color, va_list args) { /// Skip messages where level is lower than minimum logging level static char message[MAX_STRING_LEN]; vsnprintf(message, MAX_STRING_LEN - 1, format, args); if ((int)messageType >= (int)minimumLoggingLevel) { ; if (useColor) { fprintf(stderr, "\x1b[0;%dm", color); } fputs(message, stderr); if (useColor) { fprintf(stderr, "\x1b[0m\n"); } else { fprintf(stderr, "\n"); } } if (logfile.good()) { switch (messageType) { case MessageError: logfile << "ERR: "; break; case MessageWarn: logfile << "WRN: "; break; case MessageInfo: logfile << "INF: "; break; case MessageDebug: logfile << "DBG: "; break; } logfile << message << std::endl; logfile.flush(); } }
void logError(string msg,int GetLastError) { logger << msg << std::endl; if(GetLastError!=0) logger << "Error Code: " << WSAGetLastError() << std::endl; logger.flush(); }
std::string openLogfile(std::ofstream &ofLog, const std::string &sAlgo, const std::string &sGrndtr, double threshold, const std::string &sFunction) { char cLogFilename[256]; char cTmp[256]; // Determine the name of the logfile time_t rawtime; struct tm * timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); strftime(cTmp,256,"%Y-%m-%d_%H-%M-%S",timeinfo); sprintf(cLogFilename,"log/%s_%s.log",cTmp,(sAlgo.substr(sAlgo.find_last_of('/')+1)).c_str()); std::string sLogFilename(cTmp); sLogFilename += "_"+(sAlgo.substr(sAlgo.find_last_of('/')+1)); //sprintf(sLogFilename,"log/%s",sLogFilename); printf("Log File: %s\n",cLogFilename); if(!QDir("log").exists()) QDir().mkdir("log"); // Open logfile ofLog.open(cLogFilename); // Write logfile header ofLog << cLogFilename << std::endl; ofLog << std::endl; ofLog << "Algorithm: " << sAlgo << std::endl; ofLog << "Ground truth: " << sGrndtr << std::endl; ofLog << "Threshold = " << threshold << std::endl; ofLog << "Function = " << sFunction << std::endl; ofLog << std::endl; ofLog << "=====================================" << std::endl; ofLog << std::endl; ofLog.flush(); return sLogFilename; }
void end(char*,std::size_t){ file <<"{" <<"\"type\":\"FeatureCollection\"," <<"\"features\":["; bool done=false; for(std::size_t idx=0;idx<lon.size()&&!done;++idx){ file <<"{" <<"\"type\":\"Feature\"," <<"\"geometry\":" <<"{" <<"\"type\":\"Point\"," <<"\"coordinates\":["<<lon[idx]<<","<<lat[idx]<<"]" <<"}" <<"}"; file.flush(); if((std::size_t)(file.tellp())+file_thresh>=file_lim) done=true; else file<<","; } file <<"]" <<"}"; }
static void WriteOutput() { oid_t total_profile_memory = 0; for (auto &entry : state.profile_memory) { total_profile_memory += entry; } LOG_INFO("----------------------------------------------------------"); LOG_INFO("%lf %d %d :: %lf %lf %d", state.scale_factor, state.backend_count, state.warehouse_count, state.throughput, state.abort_rate, total_profile_memory); out << state.scale_factor << " "; out << state.backend_count << " "; out << state.warehouse_count << " "; out << state.throughput << " "; out << state.abort_rate << " "; out << total_profile_memory << "\n"; for (size_t round_id = 0; round_id < state.profile_throughput.size(); ++round_id) { out << "[" << std::setw(3) << std::left << state.profile_duration * round_id << " - " << std::setw(3) << std::left << state.profile_duration * (round_id + 1) << " s]: " << state.profile_throughput[round_id] << " " << state.profile_abort_rate[round_id] << " " << state.profile_memory[round_id] << "\n"; } out.flush(); out.close(); }
void Logger::flush() { if (g_logFile.is_open()) { g_logFile.flush(); } }
int main (int argc, char **argv) { DBGOPEN ("./testSplitString2.log"); try { vector<string> samples; samples.push_back ("104520,FIRST INSURANCE SOLUTIONS LTD,\"Unit 6, The Oaks Business Village\",Revenge Road,Lordswood,Chatham,Kent,ME5 8LF,UK"); samples.push_back ("104342,Towergate Risk Solutions (Lancaster),99 King Street,Lancaster,,,,LA1 1RH,UK"); samples.push_back ("104788,CU Insurance Consultants Ltd,1 Trevor Terrace,North Shields,Tyne & Wear,,,NE30 2DG,UK"); samples.push_back ("653,HOLMWOODS INSURANCE BROKERS LIMITED,LLOYDS,ONE LIME STREET,LONDON,,,EC3M 7HA,UK"); samples.push_back ("658,SNEATH KENT STUART LIMITED,\"LLOYDS OF LONDON INSURANCE,\",\"LLOYDS BUILDING,1 LIME STREET,\",LONDON,,,EC3M 7HA,UK"); samples.push_back ("663,E.J.WELTON,\"Lloyds Of London Insurance,\",\"Lloyds Building,1 Lime Street,\",London,,,EC3M 7HA,UK"); samples.push_back ("664,THOMPSON HEATH & BOND LTD,\"Murray House,Murray Road\",,,Orpington,,BR5 3QY,UK"); samples.push_back ("665,TOWERGATE STAFFORD KNIGHT & CO.LTD,55 Aldgate High Street,London,,,,EC3N 1AL,UK"); samples.push_back ("666,HOLMANS CONNECT,London Underwriting Centre,3 Minster Court,Mincing Lane,London,,EC3R 7DD,UK"); samples.push_back ("669,JOHN HOLMAN & SONS LTD,London Underwriting Centre,3 Minster Court,Mincing Lane,London,,EC3R 7DD,UK"); samples.push_back ("670,ROGER LARK & SEDGWICK,\"LLOYDS OF LONDON INSURANCE,\",\"LLOYDS BUILDING,1 LIME STREET,\",LONDON,,,EC3M 7HA,UK"); samples.push_back ("104557,Willis & Company (Insurance Brokers) Ltd,55-59 Donegall Street,Belfast,Co Antrim,,,BT1 2FH,UK"); samples.push_back ("104585,Lionheart Insurance Services Ltd,Radio House,Aston Road North,Birmingham,,,B6 4DA,UK"); samples.push_back ("105097,Oamps (UK) Ltd (Wholesale),Windsor House,High Street,Esher,,,KT10 9RY,UK"); samples.push_back ("104837,Lansdowne Woodward Ltd,Princes Court,Princes Road,Ferndown,,,BH22 9JG,UK"); samples.push_back ("104676,P J Mcilroy & Son Insurance & Investment,13 Ann Street,Ballycastle,Co. Antrim,,,BT54 6AA,UK"); samples.push_back (",,,,,,,,"); samples.push_back ("104980,D N Paterson & Company,17 Sandhead Road,Strathaven,Lanarkshire,,,ML10 6HX,UK"); samples.push_back ("104692,Sterling General Insurance Services Ltd,81 Albany Street,Regents Park,,,,NW1 4BT,UK"); string seps(","); string encs("\""); unsigned int i_count = 0; vector<string> toks3; vector<string>::iterator t; // token iterator vector<string>::const_iterator s = samples.begin(); // sample iterator. while (s != samples.end()) { toks3.clear(); toks3 = futil::splitStringWithEncs (*s, seps, encs); cout << "Output of splitStringWithEncs for the string:" << endl; // A count line: cout << "!123456789\"123456789£123456789$123456789\%123456789^123456789&123456789*123456789(123456789)123456789" << endl << *s << endl; i_count = 0; for (t = toks3.begin(); t != toks3.end(); t++) { cout << (i_count++) << ". " << *t << "\n"; } ++s; } } catch (const exception& e) { // handle error condition; should catch any // exception thrown above DBGSTREAM << "Exception: '" << e.what() << "'\n"; cerr << "Exception: '" << e.what() << "'\n"; DBGSTREAM.flush(); } DBGCLOSE(); _exit(0); }
void WriteProfiles(int in, int layer) { double parentavgms; if(in == -1) { char fullpath[MAX_PATH+1]; FullPath("profiles.txt", fullpath); g_profF.open(fullpath, std::ios_base::out); parentavgms = g_profile[TIMER_FRAME].averagems; } else { parentavgms = g_profile[in].averagems; } double ofparentpct; double totalms = 0; double totalofparentpct = 0; double percentage; int subprofiles = 0; for(int j=0; j<TIMERS; j++) { if(g_profile[j].inside != in) continue; totalms += g_profile[j].averagems; } for(int j=0; j<TIMERS; j++) { if(g_profile[j].inside != in) continue; percentage = 100.0 * g_profile[j].averagems / totalms; ofparentpct = 100.0 * g_profile[j].averagems / parentavgms; totalofparentpct += ofparentpct; subprofiles++; for(int k=0; k<layer; k++) g_profF<<"\t"; g_profF<<g_profile[j].name<<"\t...\t"<<g_profile[j].averagems<<"ms per frame, "<<percentage<<"% of this level's total"<<std::endl; WriteProfiles(j, layer+1); } if(subprofiles > 0) { for(int k=0; k<layer; k++) g_profF<<"\t"; g_profF<<"level total sum: "<<totalms<<" ms per frame, that means "<<totalofparentpct<<"% of this parent's duration underwent profiling"<<std::endl; } if(in == -1) g_profF.flush(); }
void Logger::finish() { if (g_logFile.is_open()) { g_logFile.flush(); g_logFile.close(); } }
void gen_project_foot(std::ofstream &project_file) { std::ifstream project_foot("Setup/CodeBlocks/project_foot.xml"); if(!project_foot) std::cout << "Error! project_foot.xml not found. Incomplete source." << std::endl; //Shit project_file << project_foot.rdbuf(); project_file.flush(); }
void MSBuildProvider::outputGlobalPropFile(const BuildSetup &setup, std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) { std::string warnings; for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i) warnings += *i + ';'; std::string definesList; for (StringList::const_iterator i = defines.begin(); i != defines.end(); ++i) definesList += *i + ';'; // Add define to include revision header if (runBuildEvents) definesList += REVISION_DEFINE ";"; properties << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Project DefaultTargets=\"Build\" ToolsVersion=\"" << (_version >= 12 ? _version : 4) << ".0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" "\t<PropertyGroup>\n" "\t\t<_PropertySheetDisplayName>" << setup.projectDescription << "_Global</_PropertySheetDisplayName>\n" "\t\t<ExecutablePath>$(" << LIBS_DEFINE << ")\\bin;$(ExecutablePath)</ExecutablePath>\n" "\t\t<LibraryPath>$(" << LIBS_DEFINE << ")\\lib\\" << (bits == 32 ? "x86" : "x64") << ";$(LibraryPath)</LibraryPath>\n" "\t\t<IncludePath>$(" << LIBS_DEFINE << ")\\include;$(IncludePath)</IncludePath>\n" "\t\t<OutDir>$(Configuration)" << bits << "\\</OutDir>\n" "\t\t<IntDir>$(Configuration)" << bits << "/$(ProjectName)\\</IntDir>\n" "\t</PropertyGroup>\n" "\t<ItemDefinitionGroup>\n" "\t\t<ClCompile>\n" "\t\t\t<DisableLanguageExtensions>true</DisableLanguageExtensions>\n" "\t\t\t<DisableSpecificWarnings>" << warnings << ";%(DisableSpecificWarnings)</DisableSpecificWarnings>\n" "\t\t\t<AdditionalIncludeDirectories>$(" << LIBS_DEFINE << ")\\include;" << prefix << ";" << prefix << "\\engines;" << (setup.tests ? prefix + "\\test\\cxxtest;" : "") << "$(TargetDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" "\t\t\t<PreprocessorDefinitions>" << definesList << "%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" "\t\t\t<ExceptionHandling>" << ((setup.devTools || setup.tests) ? "Sync" : "") << "</ExceptionHandling>\n"; #if NEEDS_RTTI properties << "\t\t\t<RuntimeTypeInfo>true</RuntimeTypeInfo>\n"; #else properties << "\t\t\t<RuntimeTypeInfo>false</RuntimeTypeInfo>\n"; #endif properties << "\t\t\t<WarningLevel>Level4</WarningLevel>\n" "\t\t\t<TreatWarningAsError>false</TreatWarningAsError>\n" "\t\t\t<CompileAs>Default</CompileAs>\n" "\t\t</ClCompile>\n" "\t\t<Link>\n" "\t\t\t<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>\n" "\t\t\t<SubSystem>Console</SubSystem>\n"; if (!setup.devTools && !setup.tests) properties << "\t\t\t<EntryPointSymbol>WinMainCRTStartup</EntryPointSymbol>\n"; properties << "\t\t</Link>\n" "\t\t<ResourceCompile>\n" "\t\t\t<AdditionalIncludeDirectories>" << prefix << ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" "\t\t</ResourceCompile>\n" "\t</ItemDefinitionGroup>\n" "</Project>\n"; properties.flush(); }
void _LogAppenderBase::flush() { if (!out.is_open()) { return; } out.flush(); }
void PolarGnuplotScriptGenerator::outputFooter(std::ifstream &fin, std::ofstream &fout) { std::string line; while (getline(fin, line)) { fout << line << std::endl; } fout.flush(); }
/////////////////////////////////////////////////////////////////////// // Name: AppendToLog() // Desc: add a line to global log file /////////////////////////////////////////////////////////////////////// void AppendToLog ( const char *dbgstring ) { String time( GetFormattedTime() ); debug_file << time << dbgstring << "\n"; // XXX: Flushing every time is brutally slow but helps // against losing log info if game suddenly crashes ! debug_file.flush(); }
void setOutputFile(std::string path) { if(_fileOutput.is_open()) { _fileOutput.flush(); _fileOutput.close(); } _fileOutput.open(path, std::ofstream::out | std::ofstream::app); }
void DTMImage::WriteBinaryHeader( std::ofstream &ofs ) { for ( int i = 0; i < 3; ++i ) ofs.write((char *) &this->dimensions[i], sizeof(int)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &this->origin[i], sizeof(double)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &this->spacing[i], sizeof(double)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &this->indexIncrement[i], sizeof(int)); ofs.write((char *) &this->scalarType, sizeof(int)); ofs.flush(); }
void SaveData::WriteBinaryHeader( int Dimensions[], double Origin[], double Spacing[], vtkIdType Increment[], int ScalarType, std::ofstream &ofs ) { for ( int i = 0; i < 3; ++i ) ofs.write((char *) &Dimensions[i], sizeof(int)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &Origin[i], sizeof(double)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &Spacing[i], sizeof(double)); for ( int i = 0; i < 3; ++i ) ofs.write((char *) &Increment[i], sizeof(int)); ofs.write((char *) &ScalarType, sizeof(int)); ofs.flush(); }
static void WriteOutput(double stat) { LOG_INFO("----------------------------------------------------------"); LOG_INFO("%d %d :: %lf", state.scale_factor, state.backend_count, stat); out << state.scale_factor << " "; out << state.backend_count << " "; out << stat << "\n"; out.flush(); out.close(); }
void Opcode_Log (const char* msg, ...) { va_list args; va_start (args, msg); char mesg[256]; sprintf(mesg, msg, args); gFile << mesg; gFile.flush(); va_end (args); }
void Log::Error(auto mesg) { #ifdef LOG try { file << "ERROR: " << mesg << std::endl; file.flush(); } catch(std::ofstream::failure f) { LogError("Error() write error", f); } #endif }
void Log::Verbose(auto mesg) { #ifdef LOG try { file << "VERBOSE: " << mesg << std::endl; file.flush(); } catch(std::ofstream::failure f) { LogError("Verbose() write error", f); } #endif }
void writeLogfileEntry(std::ofstream &ofLog, const std::string &sFilename, int tp, int fp, int fn) { ofLog << sFilename << std::endl; ofLog << "# faces: " << tp+fn; ofLog << ", # detected faces: " << tp+fp << std::endl; ofLog << "tp = " << tp << ", fp = " << fp << ", fn = " << fn; ofLog << ", pr = " << precision(tp, fp); ofLog << ", rc = " << recall(tp, fn) << std::endl; ofLog.flush(); }
void Log::Status(auto mesg) { #ifdef LOG try { file << "STATUS: " << mesg << std::endl; file.flush(); } catch (std::ofstream::failure f) { LogError("Status() write error", f); } #endif }
// The function flushes the file void stat_collector::flush() { // Store any data that may have been collected since the list write to the file if (m_collected_count > 0) { write_data(); m_last_store_time = boost::posix_time::microsec_clock::universal_time(); } m_csv_file.flush(); }