|
@@ -33,10 +33,6 @@ std::string const formatted_output = R"({
|
|
|
"message" : "This is a test message"
|
|
"message" : "This is a test message"
|
|
|
})";
|
|
})";
|
|
|
|
|
|
|
|
-std::string const compact_output = "{\"instant\":{\"epochSecond\":"
|
|
|
|
|
- "1554401840,\"nanoOfSecond\":123456000},\"level\":\"WARNING\","
|
|
|
|
|
- "\"loggerName\":\"UnitTest\",\"message\":\"This is a test message\"}";
|
|
|
|
|
-
|
|
|
|
|
TEST(JsonLayoutTest, LogsInformationInJSON) {
|
|
TEST(JsonLayoutTest, LogsInformationInJSON) {
|
|
|
using namespace logging;
|
|
using namespace logging;
|
|
|
auto playout = layouts::instance().get("JsonLayout", {});
|
|
auto playout = layouts::instance().get("JsonLayout", {});
|
|
@@ -49,6 +45,10 @@ TEST(JsonLayoutTest, LogsInformationInJSON) {
|
|
|
EXPECT_THAT(ss.str(), Eq(formatted_output));
|
|
EXPECT_THAT(ss.str(), Eq(formatted_output));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+std::string const compact_output = "{\"instant\":{\"epochSecond\":"
|
|
|
|
|
+ "1554401840,\"nanoOfSecond\":123456000},\"level\":\"WARNING\","
|
|
|
|
|
+ "\"loggerName\":\"UnitTest\",\"message\":\"This is a test message\"}";
|
|
|
|
|
+
|
|
|
TEST(JsonLayoutTest, CompactMeansNoWhitespace) {
|
|
TEST(JsonLayoutTest, CompactMeansNoWhitespace) {
|
|
|
using namespace logging;
|
|
using namespace logging;
|
|
|
using namespace logging::property;
|
|
using namespace logging::property;
|
|
@@ -65,6 +65,37 @@ TEST(JsonLayoutTest, CompactMeansNoWhitespace) {
|
|
|
EXPECT_THAT(ss.str(), Eq(compact_output));
|
|
EXPECT_THAT(ss.str(), Eq(compact_output));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+std::string const location_output = R"({
|
|
|
|
|
+ "instant" : {
|
|
|
|
|
+ "epochSecond" : 1554401840,
|
|
|
|
|
+ "nanoOfSecond" : 123456000
|
|
|
|
|
+ },
|
|
|
|
|
+ "level" : "WARNING",
|
|
|
|
|
+ "loggerName" : "UnitTest",
|
|
|
|
|
+ "message" : "This is a test message",
|
|
|
|
|
+ "source" : {
|
|
|
|
|
+ "file" : "json_layout_test.cxx",
|
|
|
|
|
+ "line" : 92,
|
|
|
|
|
+ "method" : "TestBody"
|
|
|
|
|
+ }
|
|
|
|
|
+})";
|
|
|
|
|
+
|
|
|
|
|
+TEST(JsonLayoutTest, ShowsLocationInfo) {
|
|
|
|
|
+ using namespace logging;
|
|
|
|
|
+ using namespace logging::property;
|
|
|
|
|
+ properties const props{_obj({
|
|
|
|
|
+ {"locationInfo", _v(true)}
|
|
|
|
|
+ })};
|
|
|
|
|
+ auto playout = layouts::instance().get("JsonLayout", props);
|
|
|
|
|
+
|
|
|
|
|
+ std::stringstream ss;
|
|
|
|
|
+ playout->format(ss, {{NOW, 123456}, level::warning, log_here, "UnitTest",
|
|
|
|
|
+ "This is a test message"});
|
|
|
|
|
+
|
|
|
|
|
+ using testing::Eq;
|
|
|
|
|
+ EXPECT_THAT(ss.str(), Eq(location_output));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
TEST(JsonLayoutTest, EOLPropertyAppendsNewline) {
|
|
TEST(JsonLayoutTest, EOLPropertyAppendsNewline) {
|
|
|
using namespace logging;
|
|
using namespace logging;
|
|
|
using namespace logging::property;
|
|
using namespace logging::property;
|