diff --git a/osal/CMakeLists.txt b/osal/CMakeLists.txt index 263a5885..934f0c16 100644 --- a/osal/CMakeLists.txt +++ b/osal/CMakeLists.txt @@ -55,7 +55,7 @@ add_library(osal OBJECT android/os_log.c linux/os_mem.c linux/os_env.c - linux/os_log.cpp + linux/os_log.c windows/os_mem.c windows/os_env.c windows/os_log.c diff --git a/osal/linux/os_log.cpp b/osal/linux/os_log.c similarity index 65% rename from osal/linux/os_log.cpp rename to osal/linux/os_log.c index 877e6aea..e39359e7 100644 --- a/osal/linux/os_log.cpp +++ b/osal/linux/os_log.c @@ -1,43 +1,23 @@ +/* SPDX-License-Identifier: Apache-2.0 OR MIT */ /* - * Copyright 2015 Rockchip Electronics Co. LTD - * - * 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. + * Copyright (c) 2015 Rockchip Electronics Co., Ltd. */ #if defined(linux) && !defined(__ANDROID__) + +#define MODULE_TAG "os_log" + #include #include #include #include "os_log.h" #include "os_env.h" +#include "mpp_singleton.h" #define LINE_SZ 1024 -class SyslogWrapper -{ -private: - // avoid any unwanted function - SyslogWrapper(const SyslogWrapper &); - SyslogWrapper &operator=(const SyslogWrapper &); -public: - SyslogWrapper(); - ~SyslogWrapper(); -}; - -static SyslogWrapper syslog_wrapper; - -SyslogWrapper::SyslogWrapper() +void syslog_wrapper_init() { int option = LOG_PID; RK_U32 syslog_perror = 1; @@ -54,7 +34,7 @@ SyslogWrapper::SyslogWrapper() openlog("mpp", option, LOG_USER); } -SyslogWrapper::~SyslogWrapper() +void syslog_wrapper_deinit() { closelog(); } @@ -101,4 +81,6 @@ void os_log_fatal(const char* tag, const char* msg, va_list list) vsyslog(LOG_CRIT, line, list); } +MPP_SINGLETON(MPP_SGLN_OS_LOG, os_log, syslog_wrapper_init, syslog_wrapper_deinit) + #endif