Go to the source code of this file.
|
| TEST_F (XlogTest, xlogName) |
|
| TEST_F (XlogTest, xlogIf) |
|
| TEST_F (XlogTest, xlog) |
|
| TEST_F (XlogTest, perFileCategoryHandling) |
|
| TEST_F (XlogTest, rateLimiting) |
|
| TEST_F (XlogTest, getXlogCategoryName) |
|
| TEST (Xlog, xlogStripFilename) |
|
TEST |
( |
Xlog |
, |
|
|
xlogStripFilename |
|
|
) |
| |
Definition at line 365 of file XlogTest.cpp.
References folly::constexpr_strcmp(), EXPECT_STREQ, and folly::xlogStripFilename().
371 "/home/johndoe/src/spacesim/ships/cruiser.cpp",
372 "/home/johndoe/src/spacesim"));
383 <<
"should only strip full directory name matches";
390 <<
"should not strip if the result will be empty";
392 <<
"empty prefixes in the prefix list should be ignored";
395 <<
"only the first prefix match should be honored";
397 <<
"only the first prefix match should be honored";
406 "src/test.cpp") == 0,
407 "incorrect xlogStripFilename() behavior");
#define EXPECT_STREQ(s1, s2)
constexpr const char * xlogStripFilename(const char *filename, const char *prefixes)
constexpr int constexpr_strcmp(const Char *s1, const Char *s2)
TEST_F |
( |
XlogTest |
, |
|
|
xlogName |
|
|
) |
| |
TEST_F |
( |
XlogTest |
, |
|
|
xlogIf |
|
|
) |
| |
Definition at line 62 of file XlogTest.cpp.
References folly::LogCategory::addHandler(), ASSERT_EQ, folly::DBG1, folly::ERR, EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, folly::LoggerDB::get(), folly::LoggerDB::getCategory(), handler(), i, folly::INFO, messages, folly::LoggerDB::setLevel(), XLOG_IF, XLOG_IS_ON, and XLOGF_IF.
63 auto handler = make_shared<TestLogHandler>();
70 XLOG_IF(INFO,
false,
"testing 1");
74 XLOG_IF(INFO,
true,
"testing 1");
79 LoggerDB::get().setLevel(
"xlog_test.main_file", LogLevel::DBG1);
80 XLOG_IF(DBG1,
false,
"testing: ", 1, 2, 3);
84 XLOG_IF(DBG1,
true,
"testing: ", 1, 2, 3);
89 std::array<bool, 2> conds = {{
false,
true}};
90 for (
unsigned i = 0;
i < conds.size();
i++) {
91 for (
unsigned j = 0; j < conds.size(); j++) {
92 XLOG_IF(DBG1, conds[
i] && conds[j],
"testing conditional");
96 XLOG_IF(DBG1, conds[
i] || conds[j],
"testing conditional");
102 XLOG_IF(DBG1, 0x6 & 0x2,
"More conditional 1");
106 XLOG_IF(DBG1, 0x6 | 0x2,
"More conditional 2");
110 XLOG_IF(DBG1, 0x6 | 0x2 ?
true :
false,
"More conditional 3");
114 XLOG_IF(DBG1, 0x6 | 0x2 ?
true :
false,
"More conditional 3");
118 XLOG_IF(DBG1, 0x3 & 0x4 ?
true :
false,
"More conditional 4");
122 XLOG_IF(DBG1,
false ?
true :
false,
"More conditional 5");
126 XLOGF_IF(DBG1,
false,
"number: {:>3d}; string: {}", 12,
"foo");
129 XLOGF_IF(DBG1,
true,
"number: {:>3d}; string: {}", 12,
"foo");
static struct message messages[5]
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
void handler(int, siginfo_t *, void *)
#define XLOG_IF(level, cond,...)
#define XLOGF_IF(level, cond, fmt, arg1,...)
#define EXPECT_TRUE(condition)
#define EXPECT_FALSE(condition)
#define XLOG_IS_ON(level)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
TEST_F |
( |
XlogTest |
, |
|
|
xlog |
|
|
) |
| |
Definition at line 134 of file XlogTest.cpp.
References folly::LogCategory::addHandler(), ASSERT_EQ, folly::DBG1, folly::DBG2, folly::ERR, EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, folly::gen::first, folly::LoggerDB::get(), folly::LoggerDB::getCategory(), handler(), folly::INFO, messages, folly::LoggerDB::setLevel(), folly::WARN, XLOG, XLOG_IS_ON, and XLOGF.
135 auto handler = make_shared<TestLogHandler>();
142 XLOG(INFO,
"testing 1");
147 LoggerDB::get().setLevel(
"xlog_test.main_file", LogLevel::DBG1);
149 XLOG(DBG1,
"testing: ", 1, 2, 3);
153 <<
"unexpected file name: " <<
messages[0].
first.getFileName();
159 XLOGF(WARN,
"number: {:>3d}; string: {}", 12,
"foo");
163 <<
"unexpected file name: " <<
messages[0].
first.getFileName();
169 XLOG(DBG2,
"this log check should not pass");
174 XLOG(INFO) <<
"stream test: " << 1 <<
", two, " << 3;
178 <<
"unexpected file name: " <<
messages[0].
first.getFileName();
static struct message messages[5]
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
void handler(int, siginfo_t *, void *)
#define EXPECT_TRUE(condition)
#define XLOGF(level, fmt, arg1,...)
#define EXPECT_FALSE(condition)
#define XLOG_IS_ON(level)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
constexpr detail::First first
TEST_F |
( |
XlogTest |
, |
|
|
perFileCategoryHandling |
|
|
) |
| |
Definition at line 185 of file XlogTest.cpp.
References folly::LogCategory::addHandler(), ASSERT_EQ, folly::DBG1, folly::DBG2, folly::DBG3, folly::DBG5, folly::DBG9, EXPECT_EQ, EXPECT_TRUE, folly::gen::first, folly::LoggerDB::get(), folly::LoggerDB::getCategory(), handler(), folly::INFO, messages, folly::LoggerDB::setLevel(), logging_test::testXlogFile1Dbg1(), logging_test::testXlogFile2Dbg1(), logging_test::testXlogHdrFunction(), and logging_test::testXlogHdrLoop().
188 auto handler = make_shared<TestLogHandler>();
190 LoggerDB::get().setLevel(
"folly.logging.test", LogLevel::DBG9);
198 <<
"unexpected file name: " <<
messages[0].
first.getFileName();
201 "folly.logging.test.XlogHeader2.h",
211 <<
"unexpected file name: " <<
messages[0].
first.getFileName();
214 "folly.logging.test.XlogHeader1.h",
230 LoggerDB::get().setLevel(
"folly.logging.test", LogLevel::DBG2);
243 "folly.logging.test.XlogFile1.cpp",
251 "folly.logging.test.XlogFile2.cpp",
257 LoggerDB::get().setLevel(
"folly.logging.test", LogLevel::INFO);
263 LoggerDB::get().setLevel(
"folly.logging.test.XlogFile1", LogLevel::DBG1);
268 "file1: this log check should pass now",
messages[0].
first.getMessage());
270 "folly.logging.test.XlogFile1.cpp",
static struct message messages[5]
void testXlogFile2Dbg1(folly::StringPiece msg)
#define ASSERT_EQ(val1, val2)
#define EXPECT_EQ(val1, val2)
void testXlogHdrFunction(folly::StringPiece str, int value)
void testXlogFile1Dbg1(folly::StringPiece msg)
void handler(int, siginfo_t *, void *)
void testXlogHdrLoop(size_t numIters, folly::StringPiece arg)
#define EXPECT_TRUE(condition)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
constexpr detail::First first
TEST_F |
( |
XlogTest |
, |
|
|
rateLimiting |
|
|
) |
| |
Definition at line 275 of file XlogTest.cpp.
References folly::LogCategory::addHandler(), folly::DBG1, testing::ElementsAre(), testing::ElementsAreArray(), EXPECT_THAT, folly::LoggerDB::get(), folly::LoggerDB::getCategory(), handler(), s, folly::LoggerDB::setLevel(), XLOG_EVERY_MS, XLOG_EVERY_N, and XLOG_N_PER_MS.
276 auto handler = make_shared<TestLogHandler>();
281 for (
size_t n = 0; n < 50; ++n) {
299 for (
size_t n = 0; n < 10; ++n) {
314 std::this_thread::sleep_for(110ms);
#define XLOG_EVERY_N(level, n,...)
void handler(int, siginfo_t *, void *)
internal::ElementsAreArrayMatcher< typename::std::iterator_traits< Iter >::value_type > ElementsAreArray(Iter first, Iter last)
#define EXPECT_THAT(value, matcher)
#define XLOG_EVERY_MS(level, ms,...)
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
#define XLOG_N_PER_MS(level, count, ms,...)
TEST_F |
( |
XlogTest |
, |
|
|
getXlogCategoryName |
|
|
) |
| |