+ // Update the options for the h2 handler using partial options
+ db.updateConfig(parseLogConfig("; h2:abc=def"));
+ EXPECT_EQ(LogLevel::INFO, db.getCategory("")->getLevel());
+ EXPECT_THAT(
+ db.getCategory("")->getHandlers(),
+ UnorderedElementsAre(
+ MatchLogHandler("handlerA", {{"stream", "stderr"}})));
+ EXPECT_EQ(LogLevel::WARN, db.getCategory("bar")->getLevel());
+ EXPECT_THAT(
+ db.getCategory("bar")->getHandlers(),
+ UnorderedElementsAre(
+ MatchLogHandler("handlerB", {{"newkey", "newvalue"}}),
+ MatchLogHandler(
+ "handlerA",
+ {{"abc", "def"}, {"foo", "xyz"}, {"reuse_handler", "1"}})));
+ EXPECT_EQ(LogLevel::INFO, db.getCategory("test.foo")->getLevel());
+ EXPECT_THAT(
+ db.getCategory("test.foo")->getHandlers(),
+ UnorderedElementsAre(MatchLogHandler(
+ "handlerA",
+ {{"abc", "def"}, {"foo", "xyz"}, {"reuse_handler", "1"}})));
+ EXPECT_EQ(
+ parseLogConfig(".:=INFO:stderr, foo:=DBG2:, bar=WARN:new:h2, "
+ "test.foo=INFO:h2; "
+ "stderr=handlerA: stream=stderr; "
+ "new=handlerB: newkey=newvalue; "
+ "h2=handlerA: reuse_handler=1,abc=def,foo=xyz"),
+ db.getConfig());
+
+ // Update the options for the "new" handler using partial options
+ db.updateConfig(parseLogConfig("; new:opt1=value1"));
+ EXPECT_EQ(LogLevel::WARN, db.getCategory("bar")->getLevel());
+ EXPECT_THAT(
+ db.getCategory("bar")->getHandlers(),
+ UnorderedElementsAre(
+ MatchLogHandler(
+ "handlerB", {{"opt1", "value1"}, {"newkey", "newvalue"}}),
+ MatchLogHandler(
+ "handlerA",
+ {{"abc", "def"}, {"foo", "xyz"}, {"reuse_handler", "1"}})));
+ EXPECT_EQ(LogLevel::INFO, db.getCategory("test.foo")->getLevel());
+ EXPECT_THAT(
+ db.getCategory("test.foo")->getHandlers(),
+ UnorderedElementsAre(MatchLogHandler(
+ "handlerA",
+ {{"abc", "def"}, {"foo", "xyz"}, {"reuse_handler", "1"}})));
+ EXPECT_EQ(
+ parseLogConfig(".:=INFO:stderr, foo:=DBG2:, bar=WARN:new:h2, "
+ "test.foo=INFO:h2; "
+ "stderr=handlerA: stream=stderr; "
+ "new=handlerB: newkey=newvalue,opt1=value1; "
+ "h2=handlerA: reuse_handler=1,abc=def,foo=xyz"),
+ db.getConfig());
+
+ // Supplying partial options for a non-existent log handler should fail
+ EXPECT_THROW_RE(
+ db.updateConfig(parseLogConfig("; no_such_handler:foo=bar")),
+ std::invalid_argument,
+ "cannot update unknown log handler \"no_such_handler\"");
+