27 using namespace folly;
43 config.getCategoryConfigs(),
51 config.getCategoryConfigs(),
58 parseLogConfig(
"my.category:=INFO , my.other.stuff := 19,foo.bar=DBG7");
60 config.getCategoryConfigs(),
71 config.getCategoryConfigs(),
77 config.getCategoryConfigs(),
82 config =
parseLogConfig(
" ERR:stderr; stderr=stream:stream=stderr ");
84 config.getCategoryConfigs(),
88 config.getHandlerConfigs(),
93 "ERR:myfile:custom, folly=DBG2, folly.io:=WARN:other;" 94 "myfile=file:path=/tmp/x.log; " 95 "custom=custom:foo=bar,hello=world,a = b = c; " 98 config.getCategoryConfigs(),
107 config.getHandlerConfigs(),
114 {{
"foo",
"bar"}, {
"hello",
"world"}, {
"a",
"b = c"}}}),
120 config.getCategoryConfigs(),
123 config.getHandlerConfigs(),
128 config.getCategoryConfigs(),
131 config.getHandlerConfigs(),
135 config =
parseLogConfig(
"ERR;test=file:path=/tmp/test.log;foo:a=b,c=d");
137 config.getCategoryConfigs(),
140 config.getHandlerConfigs(),
149 config.getHandlerConfigs(),
159 R
"(invalid log level "=" for category "")"); 163 R
"(invalid log level "bogus_level" for category ".")"); 167 R
"(invalid log level "bogus_level" for category "foo")"); 171 R
"(invalid log level "invalid" for category "bar")"); 175 R
"(invalid log level "" for category "bar")"); 179 R
"(invalid log level "" for category "bar")"); 183 R
"(invalid log level "" for category "foo")"); 187 R
"(invalid log level "x" for category ".")"); 191 R
"(invalid log level "x" for category ".")"); 195 R
"(invalid log level "" for category ".")"); 199 R
"(invalid log level "" for category "")"); 203 R
"(invalid log level "" for category "")"); 207 R
"(invalid log level "bar=ERR" for category "foo")"); 211 R
"(category "foo\.bar" listed multiple times under different names: )" 212 R"("foo\.+bar" and "foo\.+bar")"); 216 R
"(category "" listed multiple times under different names: )" 217 R"("\.?" and "\.?")"); 223 "error parsing log handler configuration: empty log handler name");
227 R
"(error parsing configuration for log handler "foo": )" 228 "empty log handler type");
232 "error parsing log handler configuration: empty log handler name");
236 "error parsing log handler configuration: empty log handler name");
240 R
"(error parsing configuration for log handler "test": )" 241 R"(invalid type "file,path=/tmp/test.log": type name cannot contain )" 242 "a comma when using the basic config format");
246 R
"(error parsing configuration for log handler "test,path": )" 247 "name cannot contain a comma when using the basic config format");
263 config.getCategoryConfigs(), 276 config.getCategoryConfigs(), 284 ".": { "level": "INFO" }, 285 "folly": { "level": "FATAL", "inherit": false }, 289 config.getCategoryConfigs(), 297 "my.category": { "level": "INFO", "inherit": true }, 298 // comments are allowed 299 "my.other.stuff": { "level": 19, "inherit": false }, 300 "foo.bar": { "level": "DBG7" }, 303 "h1": { "type": "custom", "options": {"foo": "bar", "a": "z"} } 307 config.getCategoryConfigs(), 315 config.getHandlerConfigs(),
324 " my.category ": { "level": "INFO" }, 325 " foo; bar=asdf, test": { "level": "DBG1" }, 328 "h1;h2,h3= ": { "type": " x;y " } 332 config.getCategoryConfigs(), 336 " foo; bar=asdf, test",
339 config.getHandlerConfigs(),
347 "JSON config input must be an object");
351 "JSON config input must be an object");
355 "JSON config input must be an object");
359 "JSON config input must be an object");
374 "unexpected data type for log categories config: " 375 "got integer, expected an object");
384 R"(unexpected data type for configuration of category "foo": )" 385 "got boolean, expected an object, string, or integer");
395 R"(unexpected data type for configuration of category "foo": )" 396 "got array, expected an object, string, or integer");
400 ".": { "level": "INFO" }, 401 "folly": { "level": "FATAL", "inherit": 19 }, 407 R"(unexpected data type for inherit field of category "folly": )" 408 "got integer, expected a boolean");
411 "folly": { "level": [], }, 417 R"(unexpected data type for level field of category "folly": )" 418 "got array, expected a string or integer");
429 "foo...bar": { "level": "INFO", }, 430 "foo..bar": { "level": "INFO", }, 436 R"(category "foo\.bar" listed multiple times under different names: )" 437 R"("foo\.\.+bar" and "foo\.+bar")"); 440 "...": { "level": "ERR", }, 441 "": { "level": "INFO", }, 447 R"(category "" listed multiple times under different names: )" 448 R"X("(\.\.\.|)" and "(\.\.\.|)")X"); 451 "categories": { "folly": { "level": "ERR" } }, 457 "unexpected data type for log handlers config: " 458 "got double, expected an object");
461 "categories": { "folly": { "level": "ERR" } }, 469 R"(unexpected data type for configuration of handler "foo": )" 470 "got string, expected an object");
473 "categories": { "folly": { "level": "ERR" } }, 481 R"(no handler type specified for log handler "foo")"); 484 "categories": { "folly": { "level": "ERR" } }, 494 R"(unexpected data type for "type" field of handler "foo": )" 495 "got integer, expected a string");
498 "categories": { "folly": { "level": "ERR" } }, 509 R"(unexpected data type for "options" field of handler "foo": )" 510 "got boolean, expected an object");
513 "categories": { "folly": { "level": "ERR" } }, 517 "options": ["foo", "bar"] 524 R"(unexpected data type for "options" field of handler "foo": )" 525 "got array, expected an object");
528 "categories": { "folly": { "level": "ERR" } }, 532 "options": {"bar": 5} 539 R"(unexpected data type for option "bar" of handler "foo": )" 540 "got integer, expected a string");
552 "ERROR:h1,foo.bar:=FATAL,folly=INFO:; " 553 "h1=custom:foo=bar");
574 "options": { "foo": "bar" } 585 config.getCategoryConfigs(),
592 parseLogConfig(
"WARN:default; default=custom:opt1=value1,opt2=value2");
595 config.getCategoryConfigs(),
601 config.getHandlerConfigs(),
605 "custom", {{
"opt1",
"value1"}, {
"opt2",
"value2"}}))));
610 parseLogConfig(
"WARN:default; default=custom:opt1=value1,opt2=value2");
613 config.getCategoryConfigs(),
617 config.getHandlerConfigs(),
621 "custom", {{
"opt1",
"value1"}, {
"opt2",
"value2"}}))));
624 parseLogConfig(
"WARN:default; default=custom:opt1=value1,opt2=value2");
627 config.getCategoryConfigs(),
631 config.getHandlerConfigs(),
635 "custom", {{
"opt1",
"value1"}, {
"opt2",
"value2"}}))));
639 parseLogConfig(
"WARN:default; default=custom:opt1=value1,opt2=value2");
642 config.getCategoryConfigs(),
646 config.getHandlerConfigs(),
650 "custom", {{
"opt1",
"value1"}, {
"opt2",
"value2"}}))));
654 parseLogConfig(
"WARN:default; default=stream:stream=stderr,async=false");
657 config.getCategoryConfigs(),
661 config.getHandlerConfigs(),
665 "stream", {{
"stream",
"stderr"}, {
"async",
"true"}}))));
669 parseLogConfig(
"WARN:default; default=stream:stream=stderr,async=false");
672 std::invalid_argument,
673 "cannot update configuration for " 674 R
"(unknown log handler "other")");
dynamic parseJson(StringPiece range)
#define EXPECT_THROW_RE(statement, exceptionType, pattern)
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
LogConfig parseLogConfig(StringPiece value)
internal::UnorderedElementsAreMatcher< ::testing::tuple<> > UnorderedElementsAre()
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
#define EXPECT_THAT(value, matcher)
dynamic logConfigToDynamic(const LogConfig &config)
LogConfig parseLogConfigJson(StringPiece value)
std::string toJson(dynamic const &dyn)
TEST(SequencedExecutor, CPUThreadPoolExecutor)