26 using namespace folly;
31 "{L}{m:02d}{D:02d} {H:2d}:{M:02d}:{S:02d}.{USECS:06d} " 32 "{THREAD:5d} {FILE}:{LINE}]";
34 const std::string kGlogFormatStringWithFunctionName =
35 "{L}{m:02d}{D:02d} {H:2d}:{M:02d}:{S:02d}.{USECS:06d} " 36 "{THREAD:5d} {FILE}:{LINE} {FUN}()]";
54 unsigned int lineNumber,
57 uint64_t timestampNS = 1492436756123456789ULL) {
59 auto* category = db.getCategory(
"test");
62 std::chrono::system_clock::time_point logTimePoint{
63 std::chrono::duration_cast<std::chrono::system_clock::duration>(
64 std::chrono::nanoseconds{timestampNS})};
73 return formatter.formatMessage(logMessage, category);
82 "W0417 13:45:56.123456 {:5d} myfile.cpp:1234] hello world\n", tid);
99 "W0417 13:45:56.123456 {:5d} myfile.cpp:1234] hello world\n", tid);
106 "src/test/logging/code/myfile.cpp",
112 "W0417 13:45:56.123456 {:5d} " 113 "this_is_a_really_long_file_name_that_will_probably_exceed_" 114 "our_buffer_allocation_guess.cpp:123456789] oh noes\n",
122 "this_is_a_really_long_file_name_that_will_probably_exceed_" 123 "our_buffer_allocation_guess.cpp",
133 "W0417 13:45:56.123456 {:5d} myfile.cpp:1234 testFunction()] " 139 kGlogFormatStringWithFunctionName,
142 "src/test/logging/code/myfile.cpp",
149 std::map<std::string, std::string> formatMap{
150 {
"tid", folly::to<std::string>(tid)}};
154 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] Eeek, a mouse!\n" 155 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] . .\n" 156 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] ( ).( )\n" 157 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] (o o) .-._.'\n" 158 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] ( - )\n" 159 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] mm mm\n" 160 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] \n" 161 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] =============\n",
183 std::map<std::string, std::string> formatMap{
184 {
"tid", folly::to<std::string>(tid)}};
188 "V0417 13:45:56.123456 {tid:>5s} foo.txt:123] \n" 189 "V0417 13:45:56.123456 {tid:>5s} foo.txt:123] \n",
204 std::map<std::string, std::string> formatMap{
205 {
"tid", folly::to<std::string>(tid)}};
210 "\033[1;30mV0417 13:45:56.123456 {tid:>5s} foo.txt:123] DBG9\033[0m\n",
226 "I0417 13:45:56.123456 {tid:>5s} foo.txt:123] INFO\n", formatMap);
241 "\033[33mW0417 13:45:56.123456 {tid:>5s} foo.txt:123] WARN\033[0m\n",
257 "\033[31mE0417 13:45:56.123456 {tid:>5s} foo.txt:123] ERR\033[0m\n",
273 "\033[1;41mC0417 13:45:56.123456 {tid:>5s} foo.txt:123] " 290 "\033[1;41mF0417 13:45:56.123456 {tid:>5s} foo.txt:123] " 311 "E0417 13:45:56.123456 {:5d} escapes.cpp:97] foo\\x07bar\\x1btest\n",
323 "I0417 13:45:56.123456 {:5d} escapes.cpp:98] foo\\\\bar\"test\n", tid);
334 "C0417 13:45:56.123456 {:5d} escapes.cpp:99] nul\\x00byte\n", tid);
359 "I msg\n", formatMsg(
"{L}",
LogLevel::INFO,
"msg",
"file",
"fun", 99));
365 formatMsg(
"{L}:{LINE:03}",
LogLevel::ERR,
"msg",
"file",
"fun", 99));
368 formatMsg(
"{{L}}:{LINE:03}",
LogLevel::ERR,
"msg",
"file",
"fun", 99));
371 formatMsg(
"{L}:{LINE:03}{{",
LogLevel::ERR,
"msg",
"file",
"fun", 99));
374 formatMsg(
"{L}:{LINE:03}}}",
LogLevel::ERR,
"msg",
"file",
"fun", 99));
377 formatMsg(
"{{{L}}}",
LogLevel::ERR,
"msg",
"file",
"fun", 99));
391 setenv(
"TZ",
"UTC", 1);
#define EXPECT_THROW(statement, expected_exception)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
std::string sformat(StringPiece fmt, Args &&...args)
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
void init(int *argc, char ***argv, bool removeFlags)
std::string svformat(StringPiece fmt, Container &&container)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
TEST(SequencedExecutor, CPUThreadPoolExecutor)