#include #include #include #include #include "utils/logger.h" #include "../plugins/alarm/actions/log_action.h" namespace rk3588 { namespace { TEST(LogActionTest, IncludesFaceRecognitionDetailsInAlarmLog) { Logger::Instance().SetLevel(LogLevel::Info); LogAction action; SimpleJson cfg(SimpleJson::Object{ {"level", SimpleJson(std::string("info"))}, {"include_detections", SimpleJson(true)}, }); ASSERT_TRUE(action.Init(cfg)); AlarmEvent event; event.event_id = "cam1_alarm_42_1"; event.node_id = "alarm_face_cam1"; event.rule_name = "unknown_face"; event.frame_id = 42; Detection det; det.cls_id = -1; det.score = 0.44f; det.bbox = Rect{10.0f, 20.0f, 30.0f, 40.0f}; det.track_id = -1; event.detections.push_back(det); FaceAlarmMatch match; match.status = FaceAlarmStatus::Unknown; match.candidate_person_id = 7; match.candidate_name = "alice"; match.best_sim = 0.44f; match.second_sim = 0.41f; event.face_matches.push_back(match); action.Execute(event, std::make_shared()); const auto lines = Logger::Instance().RecentLines(10); ASSERT_FALSE(lines.empty()); const std::string& line = lines.back(); EXPECT_NE(line.find("event_id=cam1_alarm_42_1"), std::string::npos); EXPECT_NE(line.find("rule=unknown_face"), std::string::npos); EXPECT_NE(line.find("candidate=alice"), std::string::npos); EXPECT_NE(line.find("status=unknown"), std::string::npos); EXPECT_NE(line.find("best_sim=0.44"), std::string::npos); EXPECT_NE(line.find("second_sim=0.41"), std::string::npos); EXPECT_NE(line.find("sim_margin=0.03"), std::string::npos); } } // namespace } // namespace rk3588