26 using namespace folly;
43 unsigned int lineNumber,
46 uint64_t timestampNS = 1492436756123456789ULL) {
48 auto* category = db.getCategory(
"test");
51 std::chrono::system_clock::time_point logTimePoint{
52 std::chrono::duration_cast<std::chrono::system_clock::duration>(
53 std::chrono::nanoseconds{timestampNS})};
71 "W0417 13:45:56.123456 {:5d} myfile.cpp:1234] hello world\n", tid);
75 LogLevel::WARN,
"hello world",
"myfile.cpp", 1234,
"testFunction"));
78 TEST(GlogFormatter, filename) {
83 "W0417 13:45:56.123456 {:5d} myfile.cpp:1234] hello world\n", tid);
89 "src/test/logging/code/myfile.cpp",
95 "W0417 13:45:56.123456 {:5d} " 96 "this_is_a_really_long_file_name_that_will_probably_exceed_" 97 "our_buffer_allocation_guess.cpp:123456789] oh noes\n",
104 "this_is_a_really_long_file_name_that_will_probably_exceed_" 105 "our_buffer_allocation_guess.cpp",
110 TEST(GlogFormatter, multiline) {
112 std::map<std::string, std::string> formatMap{
113 {
"tid", folly::to<std::string>(tid)}};
117 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] Eeek, a mouse!\n" 118 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] . .\n" 119 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] ( ).( )\n" 120 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] (o o) .-._.'\n" 121 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] ( - )\n" 122 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] mm mm\n" 123 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] \n" 124 "V0417 13:45:56.123456 {tid:>5s} rodent.cpp:777] =============\n",
143 TEST(GlogFormatter, singleNewline) {
145 std::map<std::string, std::string> formatMap{
146 {
"tid", folly::to<std::string>(tid)}};
150 "V0417 13:45:56.123456 {tid:>5s} foo.txt:123] \n" 151 "V0417 13:45:56.123456 {tid:>5s} foo.txt:123] \n",
158 TEST(GlogFormatter, unprintableChars) {
163 "E0417 13:45:56.123456 {:5d} escapes.cpp:97] foo\\x07bar\\x1btest\n",
174 "I0417 13:45:56.123456 {:5d} escapes.cpp:98] foo\\\\bar\"test\n", tid);
178 LogLevel::INFO,
"foo\\bar\"test",
"escapes.cpp", 98,
"testFunction"));
180 "C0417 13:45:56.123456 {:5d} escapes.cpp:99] nul\\x00byte\n", tid);
202 setenv(
"TZ",
"UTC", 1);
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)