MCPcopy Create free account
hub / github.com/ChunelFeng/CThreadPool / CGRAPH_ECHO

Function CGRAPH_ECHO

src/UtilsCtrl/UtilsFunction.h:27–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 */
26static std::mutex g_echo_mtx;
27inline CVoid CGRAPH_ECHO(const char *cmd, ...) {
28#ifdef _CGRAPH_SILENCE_
29 return;
30#endif
31
32 std::lock_guard<std::mutex> lock{ g_echo_mtx };
33#ifndef _WIN32
34 // 非windows系统,打印到毫秒
35 auto now = std::chrono::system_clock::now();
36 // 通过不同精度获取相差的毫秒数
37 uint64_t disMs = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count()
38 - std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count() * 1000;
39 time_t tt = std::chrono::system_clock::to_time_t(now);
40 auto localTime = localtime(&tt);
41 char strTime[32] = { 0 };
42 sprintf(strTime, "[%04d-%02d-%02d %02d:%02d:%02d.%03d]", localTime->tm_year + 1900,
43 localTime->tm_mon + 1, localTime->tm_mday, localTime->tm_hour,
44 localTime->tm_min, localTime->tm_sec, (int)disMs);
45 std::cout << "[CGraph] " << strTime << " ";
46#else
47 // windows系统,打印到秒
48 time_t curTime;
49 time(&curTime);
50 std::string ct = ctime(&curTime);
51 std::cout << "[CGraph] ["
52 << ct.assign(ct.begin(), ct.end()-1) // 去掉时间的最后一位\n信息
53 << "] ";
54#endif
55
56 va_list args;
57 va_start(args, cmd);
58 vprintf(cmd, args);
59 va_end(args);
60 std::cout << "\n";
61}
62
63
64/**

Callers 5

tutorial_threadpool_2Function · 0.85
tutorial_threadpool_3Function · 0.85
mainFunction · 0.85
setSchedParamFunction · 0.85
setAffinityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected