Remove log_manager (dlog redirects stdout and stderr by itself) accepted/tizen/unified/20210406.083608 submit/tizen/20210406.003726
authorHyungju Lee <leee.lee@samsung.com>
Mon, 5 Apr 2021 21:49:30 +0000 (06:49 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Tue, 6 Apr 2021 00:38:08 +0000 (09:38 +0900)
NativeLauncher/CMakeLists.txt
NativeLauncher/inc/log_manager.h [deleted file]
NativeLauncher/launcher/lib/core_runtime.cc
NativeLauncher/util/log_manager.cc [deleted file]

index fc67894..ab4de99 100644 (file)
@@ -112,7 +112,6 @@ SET(${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES
     util/utils.cc
     util/plugin_manager.cc
     util/path_manager.cc
-    util/log_manager.cc
 )
 ADD_LIBRARY(${DOTNET_LAUNCHER_UTIL} SHARED ${${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER_UTIL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
diff --git a/NativeLauncher/inc/log_manager.h b/NativeLauncher/inc/log_manager.h
deleted file mode 100644 (file)
index 2f4bf89..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __LOG_MANAGER_H__
-#define __LOG_MANAGER_H__
-
-int initializeLogManager();
-int redirectFD();
-
-#endif /* __LOG_MANAGER_H__ */
index 2a39b0a..1e5fb5e 100644 (file)
@@ -46,7 +46,6 @@
 #include "core_runtime.h"
 #include "plugin_manager.h"
 #include "path_manager.h"
-#include "log_manager.h"
 
 namespace tizen {
 namespace runtime {
@@ -385,12 +384,7 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode)
                __pm->addPlatformAssembliesPaths(pluginPath);
        }
 
-       if (!pluginHasLogControl()) {
-               if (initializeLogManager() < 0) {
-                       _ERR("Failed to initnialize LogManager");
-                       return -1;
-               }
-       }
+       pluginHasLogControl();
 
        std::string libCoreclr(concatPath(__pm->getRuntimePath(), "libcoreclr.so"));
 
@@ -526,14 +520,6 @@ 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 LogManager is not initialized, below redirectFD will return 0;
-       if (redirectFD() < 0) {
-               _ERR("Failed to redirect FD");
-               return -1;
-       }
-
        // VD has their own signal handler.
        if (!pluginHasLogControl()) {
                registerSigHandler();
diff --git a/NativeLauncher/util/log_manager.cc b/NativeLauncher/util/log_manager.cc
deleted file mode 100644 (file)
index 72f48cd..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include "log.h"
-#include "log_manager.h"
-
-static int __pfd[2];
-static pthread_t __loggingThread;
-static bool __isInit = false;
-
-static void *stdlog(void*)
-{
-       ssize_t readSize;
-       char buf[1024];
-
-       while ((readSize = read(__pfd[0], buf, sizeof buf - 1)) > 0) {
-               if (buf[readSize - 1] == '\n') {
-                       --readSize;
-               }
-
-               buf[readSize] = 0;
-
-               _LOGX("%s", buf);
-       }
-
-       close(__pfd[0]);
-       close(__pfd[1]);
-
-       return 0;
-}
-
-int initializeLogManager()
-{
-       __isInit = true;
-
-       if (setvbuf(stdout, NULL, _IOLBF, 0) < 0) {
-               _ERR("fail to make stdout line-buffered");
-               return -1;
-       }
-
-       if (setvbuf(stderr, NULL, _IONBF, 0) < 0) {
-               _ERR("make stderr unbuffered");
-               return -1;
-       }
-
-       /* create the pipe and redirect stdout and stderr */
-       if (pipe(__pfd) < 0) {
-               _ERR("fail to create pipe for logging");
-               return -1;
-       }
-
-       /* redirect stdout and stderr */
-       if (redirectFD() < 0) {
-               return -1;
-       }
-
-       /* spawn the logging thread */
-       if (pthread_create(&__loggingThread, 0, stdlog, 0) != 0) {
-               _ERR("fail to create pthread");
-               return -1;
-       }
-
-       if (pthread_detach(__loggingThread) != 0) {
-               _ERR("fail to detach pthread");
-               return -1;
-       }
-
-       return 0;
-}
-
-// launchpad override stdout and stderr to journalctl before launch application.
-// So, even though fd redirection is done in initializeLogManager, we do it again before launch.
-// if LogManager is not initialized, it will return 0;
-int redirectFD()
-{
-       if (!__isInit)
-               return 0;
-
-       if (__pfd[1] < 0) {
-               _ERR("fail to create pipe for logging");
-               return -1;
-       }
-
-       // stdout
-       if (dup2(__pfd[1], 1) == -1) {
-               _ERR("fail to duplicate fd to stdout");
-               return -1;
-       }
-
-       // stderr
-       if (dup2(__pfd[1], 2) == -1) {
-               _ERR("fail to duplicate fd to stderr");
-               return -1;
-       }
-
-       return 0;
-}