From: Woongsuk Cho Date: Fri, 27 Jul 2018 04:23:40 +0000 (+0900) Subject: add plugin interface to check log control X-Git-Tag: accepted/tizen/unified/20180802.134837~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F185206%2F1;p=platform%2Fcore%2Fdotnet%2Flauncher.git add plugin interface to check log control Change-Id: Ib6ad49a13b8064582d100be10d08b7f8ded8ef8d --- diff --git a/NativeLauncher/inc/dotnet_launcher_plugin.h b/NativeLauncher/inc/dotnet_launcher_plugin.h index 21967c4..332c9f1 100644 --- a/NativeLauncher/inc/dotnet_launcher_plugin.h +++ b/NativeLauncher/inc/dotnet_launcher_plugin.h @@ -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 diff --git a/NativeLauncher/inc/plugin_manager.h b/NativeLauncher/inc/plugin_manager.h index 0e8cacd..f029750 100644 --- a/NativeLauncher/inc/plugin_manager.h +++ b/NativeLauncher/inc/plugin_manager.h @@ -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(); diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 2e65927..884a5a2 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -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); diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.h b/NativeLauncher/launcher/dotnet/dotnet_launcher.h index 6d32a77..8be7617 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.h +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.h @@ -46,6 +46,7 @@ class CoreRuntime unsigned int __domainId; int fd; bool __initialized; + bool __enableLogManager; }; } // dotnetcore diff --git a/NativeLauncher/util/plugin_manager.cc b/NativeLauncher/util/plugin_manager.cc index 172f302..227e0a2 100644 --- a/NativeLauncher/util/plugin_manager.cc +++ b/NativeLauncher/util/plugin_manager.cc @@ -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) {