Add some logs for parser
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 Feb 2025 05:58:21 +0000 (14:58 +0900)
committer장상윤/Tizen Platform Lab(SR)/삼성전자 <jeremy.jang@samsung.com>
Tue, 4 Feb 2025 06:20:43 +0000 (15:20 +0900)
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
CMakeLists.txt
src/pkgmgr_plugin_parser/json_action_schema_parser.cc
src/pkgmgr_plugin_parser/sqlite_db.cc
src/pkgmgr_plugin_parser/tizen_action_metadata_plugin.cc

index eaf8d11831299fef2324f6070014a5ba306b1d97..d6a6c2debc9f993df25cecc624cdd0c7d602cd11 100644 (file)
@@ -25,7 +25,7 @@ SET(TARGET_TIZEN_ACTION_PLUGIN "tizen-action-plugin")
 INCLUDE(FindPkgConfig)
 INCLUDE(ApplyPkgConfig)
 
-ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_ACTION_MANAGER\"")
+ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_ACTION_FRAMEWORK\"")
 
 ## Find all needed packages once
 PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
index 21beaa013e6b5001f1b360f6521f65ef8b6403b5..b0c4a2af00f6f108a91a1e62a13033b2582ae168 100644 (file)
@@ -28,6 +28,7 @@ namespace {
 
 std::string JsonToString(const Json::Value& val) {
   Json::StreamWriterBuilder builder;
+  builder["indentation"] = "";
   const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
   return Json::writeString(builder, val);
 }
@@ -53,7 +54,10 @@ ActionSchema JsonActionSchemaParser::Parse(const std::string& pkgid,
   std::string name = root["name"].asString();
   std::string json_str = JsonToString(root);
 
-  return ActionSchema(pkgid, name, "dd");
+  LOG(DEBUG) << "Parased action for pkgid[ " << pkgid << " ] : " << name;
+  LOG(DEBUG) << json_str;
+
+  return ActionSchema(pkgid, name, json_str);
 }
 
 }  // namespace parser
index bcb3d8008501bca89ab4aba2b1333c4c9dd9a90b..91961034dcd2e9dee28b545f21c6ba4812d2d8c2 100644 (file)
@@ -54,7 +54,8 @@ bool SqliteDb::Install(const ActionSchema& schema) {
       .Bind(schema.GetJsonStr()));
   auto r = conn_.Exec(q);
   if (!static_cast<bool>(r)) {
-    LOG(ERROR) << "Failed to insert action schema: " << schema.GetName();
+    LOG(ERROR) << "Failed to insert action schema: " << schema.GetName()
+        << ", error: " << static_cast<const char*>(r);
     return false;
   }
 
@@ -68,7 +69,7 @@ bool SqliteDb::Update(const ActionSchema& schema) {
   auto r = conn_.Exec(q);
   if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to delete action schema from DB: "
-        << schema.GetName();
+        << schema.GetName() << ", error: " << static_cast<const char*>(r);
     return false;
   }
 
@@ -80,7 +81,7 @@ bool SqliteDb::Update(const ActionSchema& schema) {
   r = conn_.Exec(q);
   if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to update action schema into DB: "
-        << schema.GetName();
+        << schema.GetName() << ", error: " << static_cast<const char*>(r);
     return false;
   }
 
@@ -92,7 +93,8 @@ bool SqliteDb::Uninstall(const ActionSchema& schema) {
       .Bind(schema.GetPkgId()));
   auto r = conn_.Exec(q);
   if (!static_cast<bool>(r)) {
-    LOG(ERROR) << "Failed to delete action schema: " << schema.GetName();
+    LOG(ERROR) << "Failed to delete action schema: " << schema.GetName()
+        << ", error: " << static_cast<const char*>(r);
     return false;
   }
 
index edf9f4a8a9d10cdbd3694de9a29f9f86a927d944..124cbe6ae814bc150614811e0f32aa28982fd141 100644 (file)
@@ -71,6 +71,8 @@ bool IsPlatformPrivilege() {
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(
     const char* pkgid, const char* appid, GList* metadata) {
+  LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_INSTALL";
+
   std::string root_path = GetActionSchemaFilePath(pkgid);
   if (root_path.empty())
     return -1;
@@ -80,15 +82,19 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(
     if (strcmp(md->key, kActionKey) != 0)
       continue;
     json_file = root_path + md->value;
+    LOG(DEBUG) << "Try parsing json file: " << json_file;
     parser::ActionParser parser;
     parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
     parser.Commit(parser::ActionParser::Operation::Install, schema);
   }
+  LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_INSTALL";
   return 0;
 }
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(
     const char* pkgid, const char* appid, GList* metadata) {
+  LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UPGRADE";
+
   std::string root_path = GetActionSchemaFilePath(pkgid);
   if (root_path.empty())
     return -1;
@@ -98,16 +104,21 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(
     if (strcmp(md->key, kActionKey) != 0)
       continue;
     json_file = root_path + md->value;
+    LOG(DEBUG) << "Try parsing json file: " << json_file;
     parser::ActionParser parser;
     // TODO: remove and install?
     parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
     parser.Commit(parser::ActionParser::Operation::Update, schema);
   }
+
+  LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UPGRADE";
   return 0;
 }
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(
     const char* pkgid, const char* appid, GList* metadata) {
+  LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
+
   std::string root_path = GetActionSchemaFilePath(pkgid);
   if (root_path.empty())
     return -1;
@@ -115,6 +126,8 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(
   std::string json_file;
   for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
     if (!strcmp(md->key, kActionKey)) {
+      json_file = root_path + md->value;
+      LOG(DEBUG) << "Try parsing json file: " << json_file;
       parser::ActionParser parser;
       parser::ActionSchema schema = parser.Inflate(pkgid, json_file);
       // TODO: uninstall without parsing
@@ -122,18 +135,24 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(
       break;
     }
   }
+
+  LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UNINSTALL";
   return 0;
 }
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(
     const char* pkgid, const char* appid, GList* metadata) {
   // TODO
+  LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_CLEAN";
+  LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_CLEAN";
   return 0;
 }
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(
     const char* pkgid, const char* appid, GList* metadata) {
   // plugin cannot decide that what type undo of current process is
+  LOG(DEBUG) << "++ PKGMGR_MDPARSER_PLUGIN_UNDO";
+  LOG(DEBUG) << "-- PKGMGR_MDPARSER_PLUGIN_UNDO";
   return 0;
 }