mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-09-26 21:15:53 +08:00
refactor[osal/linux/os_log]: Use C constructor.
Change-Id: I178b570db0131965deecbcf536ab8f680a35c46f Signed-off-by: Chandler Chen <chandler.chen@rock-chips.com> Signed-off-by: Hongjin Li <vic.hong@rock-chips.com>
This commit is contained in:
@@ -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
|
||||
|
@@ -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 <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#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
|
Reference in New Issue
Block a user