add plugin interface to check log control 06/185206/1
authorWoongsuk Cho <ws77.cho@samsung.com>
Fri, 27 Jul 2018 04:23:40 +0000 (13:23 +0900)
committerWoongsuk Cho <ws77.cho@samsung.com>
Fri, 27 Jul 2018 04:23:40 +0000 (13:23 +0900)
Change-Id: Ib6ad49a13b8064582d100be10d08b7f8ded8ef8d

NativeLauncher/inc/dotnet_launcher_plugin.h
NativeLauncher/inc/plugin_manager.h
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/launcher/dotnet/dotnet_launcher.h
NativeLauncher/util/plugin_manager.cc

index 21967c4..332c9f1 100644 (file)
@@ -33,6 +33,12 @@ extern "C"
        void plugin_preload();
 
        /**
+        * @brief check whether plugin controls output log or not.
+        * @return true if plugin control logging, otherwise false
+        */
+       bool plugin_has_log_control();
+
+       /**
         * @brief set appInfo to plugin
         * @param[in] appID application ID to launch
         * @param[in] assemblyPath assembly path which has entry point
index 0e8cacd..f029750 100644 (file)
@@ -24,6 +24,7 @@ typedef void (*plugin_preload_ptr)();
 typedef void (*plugin_set_app_info_ptr)(
                        const char* appId,
                        const char* managedAssemblyPath);
+typedef bool (*plugin_has_log_control_ptr)();
 typedef void (*plugin_set_coreclr_info_ptr)(
                        void* hostHandle,
                        unsigned int domainId,
@@ -35,6 +36,7 @@ typedef void (*plugin_finalize_ptr)();
 typedef struct PluginFunc {
        plugin_initialize_ptr initialize;
        plugin_preload_ptr preload;
+       plugin_has_log_control_ptr has_log_control;
        plugin_set_app_info_ptr set_app_info;
        plugin_set_coreclr_info_ptr set_coreclr_info;
        plugin_get_dll_path_ptr get_dll_path;
@@ -44,6 +46,7 @@ typedef struct PluginFunc {
 
 // plugin functions
 void pluginPreload();
+bool pluginHasLogControl();
 void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath);
 void pluginSetCoreclrInfo(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc);
 char* pluginGetDllPath();
index 2e65927..884a5a2 100644 (file)
@@ -136,6 +136,12 @@ CoreRuntime::CoreRuntime(const char* mode) :
        if (initializePluginManager(mode) < 0) {
                _ERR("Failed to initialize PluginManager");
        }
+
+       if (pluginHasLogControl()) {
+               __enableLogManager = false;
+       } else {
+               __enableLogManager = true;
+       }
 }
 
 CoreRuntime::~CoreRuntime()
@@ -177,19 +183,21 @@ int CoreRuntime::initialize(bool standalone)
                return -1;
        }
 
-       if (initializeLogManager() < 0) {
-               _ERR("Failed to initnialize LogManager");
-               return -1;
-       }
+       if (__enableLogManager) {
+               if (initializeLogManager() < 0) {
+                       _ERR("Failed to initnialize LogManager");
+                       return -1;
+               }
 
-       if (redirectFD() < 0) {
-               _ERR("Failed to redirect FD");
-               return -1;
-       }
+               if (redirectFD() < 0) {
+                       _ERR("Failed to redirect FD");
+                       return -1;
+               }
 
-       if (runLoggingThread() < 0) {
-               _ERR("Failed to create and run logging thread to redicrect log");
-               return -1;
+               if (runLoggingThread() < 0) {
+                       _ERR("Failed to create and run logging thread to redicrect log");
+                       return -1;
+               }
        }
 
        std::string libCoreclr(concatPath(getRuntimeDir(), "libcoreclr.so"));
@@ -327,11 +335,13 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i
                return -1;
        }
 
-       // launchpad override stdout and stderr to journalctl before launch application.
-       // we have to re-override that to input pipe for logging thread.
-       if (redirectFD() < 0) {
-               _ERR("Failed to redirect FD");
-               return -1;
+       if (__enableLogManager) {
+               // launchpad override stdout and stderr to journalctl before launch application.
+               // we have to re-override that to input pipe for logging thread.
+               if (redirectFD() < 0) {
+                       _ERR("Failed to redirect FD");
+                       return -1;
+               }
        }
 
        pluginSetAppInfo(appId, path);
index 6d32a77..8be7617 100644 (file)
@@ -46,6 +46,7 @@ class CoreRuntime
                unsigned int __domainId;
                int fd;
                bool __initialized;
+               bool __enableLogManager;
 };
 
 }  // dotnetcore
index 172f302..227e0a2 100644 (file)
@@ -36,6 +36,7 @@ int initializePluginManager(const char* mode)
                        }
                        __pluginFunc->initialize = (plugin_initialize_ptr)dlsym(__pluginLib, "plugin_initialize");
                        __pluginFunc->preload = (plugin_preload_ptr)dlsym(__pluginLib, "plugin_preload");
+                       __pluginFunc->has_log_control = (plugin_has_log_control_ptr)dlsym(__pluginLib, "plugin_has_log_control");
                        __pluginFunc->set_app_info = (plugin_set_app_info_ptr)dlsym(__pluginLib, "plugin_set_app_info");
                        __pluginFunc->set_coreclr_info = (plugin_set_coreclr_info_ptr)dlsym(__pluginLib, "plugin_set_coreclr_info");
                        __pluginFunc->get_dll_path = (plugin_get_dll_path_ptr)dlsym(__pluginLib, "plugin_get_dll_path");
@@ -75,6 +76,15 @@ void pluginPreload()
        }
 }
 
+bool pluginHasLogControl()
+{
+       if (__pluginFunc && __pluginFunc->has_log_control) {
+               return __pluginFunc->has_log_control();
+       } else {
+               return false;
+       }
+}
+
 void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath)
 {
        if (__pluginFunc && __pluginFunc->set_app_info) {