mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-06 01:26:49 +08:00
[rk_log]: add os_log function on window
separate os_log and platform log function git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@10 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
# vim: syntax=cmake
|
||||
if(${ANDROID})
|
||||
set(OS_DIR android)
|
||||
elseif(${UNIX})
|
||||
set(OS_DIR linux)
|
||||
elseif(${WIN32})
|
||||
set(OS_DIR window)
|
||||
else()
|
||||
message(SEND_ERROR "Can not found platform definistion ${CMAKE_SYSTEM}")
|
||||
endif()
|
||||
|
||||
set(OSAL_HDR
|
||||
inc/rk_list.h
|
||||
inc/rk_thread.h
|
||||
inc/rk_log.h
|
||||
os_log.h
|
||||
)
|
||||
|
||||
set(OSAL_SRC
|
||||
rk_list.cpp
|
||||
rk_log.cpp
|
||||
${OS_DIR}/os_log.c
|
||||
)
|
||||
|
||||
add_library(osal STATIC
|
||||
${OSAL_SRC}
|
||||
${OSAL_SRC} ${OSAL_HDR}
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
@@ -19,31 +19,37 @@
|
||||
|
||||
#include "rk_type.h"
|
||||
|
||||
/*
|
||||
* C log functions
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* STATIC_LOG_LEVE is for
|
||||
*/
|
||||
#define STATIC_LOG_LEVE (0xffffffff)
|
||||
|
||||
#ifdef STATIC_LOG_LEVE
|
||||
#define rk_debug STATIC_LOG_LEVE
|
||||
#else
|
||||
extern RK_U32 rk_debug;
|
||||
#ifndef LOG_TAG
|
||||
#define LOG_TAG "rk_log"
|
||||
#endif
|
||||
|
||||
void rk_set_log_flag(RK_U32 flag);
|
||||
RK_U32 rk_get_log_flag();
|
||||
|
||||
#define rk_log(fmt, ...) _rk_log(LOG_TAG, fmt, ## __VA_ARGS__)
|
||||
#define rk_err(fmt, ...) _rk_err(LOG_TAG, fmt, ## __VA_ARGS__)
|
||||
|
||||
#define rk_dbg(debug, flag, fmt, ...) \
|
||||
do { \
|
||||
if (debug & flag) { \
|
||||
_rk_log(LOG_TAG, fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Send the specified message to the log
|
||||
* rk_log : general log function
|
||||
* rk_err : log function for error information
|
||||
* _rk_log : general log function, send log to stdout
|
||||
* _rk_err : log function for error information, send log to stderr
|
||||
*/
|
||||
void rk_log(const char *fmt, ...);
|
||||
void rk_err(const char *fmt, ...);
|
||||
void _rk_log(const char *tag, const char *fmt, ...);
|
||||
void _rk_err(const char *tag, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* debug flag usage:
|
||||
@@ -55,14 +61,19 @@ void rk_err(const char *fmt, ...);
|
||||
* 24~31 bit: information print format
|
||||
*/
|
||||
/*
|
||||
* 0~ 3 bit:
|
||||
* dynamic debug function
|
||||
* rk_dbg_add_flag : add a new debug flag associated with module name
|
||||
* rk_dbg_set_flag : set a existing debug flag associated with module name
|
||||
* rk_dbg_show_flag : show all existing debug flags
|
||||
*/
|
||||
|
||||
//void rk_dbg(RK_U32 debug, RK_U32 flag, const char *tag, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* submodules suggest to use macro as below:
|
||||
* #define h264d_dbg(flag, const char *fmt, ...) \
|
||||
* rk_dbg(h264d_debug, flag, fmt, ## __VA_ARGS__)
|
||||
*/
|
||||
#define rk_dbg(flag, debug, fmt, ...) \
|
||||
do { \
|
||||
if (debug & flag) { \
|
||||
rk_log(fmt, ## __VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
39
osal/os_log.h
Normal file
39
osal/os_log.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2010 Rockchip Electronics S.LSI 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* all os log function will provide two interface
|
||||
* os_log and os_err
|
||||
* os_log for general message
|
||||
* os_err for error message
|
||||
*/
|
||||
|
||||
#ifndef __OS_LOG_H__
|
||||
#define __OS_LOG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void os_log(const char* tag, const char* msg, va_list list);
|
||||
void os_err(const char* tag, const char* msg, va_list list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__OS_LOG_H__*/
|
||||
|
@@ -17,40 +17,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "rk_log.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <utils/Log.h>
|
||||
#endif
|
||||
|
||||
#include "os_log.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static RK_U32 mpp_log_flag = 0;
|
||||
static void (*rk_log_callback)(const char*, const char*, va_list) = os_log;
|
||||
static void (*rk_err_callback)(const char*, const char*, va_list) = os_err;
|
||||
|
||||
void rk_log(const char *fmt, ...)
|
||||
void _rk_log(const char *tag, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
#ifdef ANDROID
|
||||
ALOGI(fmt, args);
|
||||
#else
|
||||
vfprintf(stdout, fmt, args);
|
||||
#endif
|
||||
rk_log_callback(tag, fmt, args);
|
||||
va_end(args);
|
||||
return ;
|
||||
}
|
||||
|
||||
void rk_err(const char *fmt, ...)
|
||||
void _rk_err(const char *tag, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
#ifdef ANDROID
|
||||
ALOGE(fmt, args);
|
||||
#else
|
||||
vfprintf(stderr, fmt, args);
|
||||
#endif
|
||||
rk_err_callback(tag, fmt, args);
|
||||
va_end(args);
|
||||
return ;
|
||||
}
|
||||
|
@@ -13,6 +13,6 @@ endif()
|
||||
option(OSAL_THREAD_TEST "Build osal rk_thread unit test" ON)
|
||||
if(OSAL_THREAD_TEST)
|
||||
add_executable(rk_thread_test rk_thread_test.c)
|
||||
target_link_libraries(rk_thread_test pthread osal)
|
||||
target_link_libraries(rk_thread_test osal)
|
||||
endif()
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "rk_log_test"
|
||||
#include "rk_log.h"
|
||||
|
||||
|
||||
|
35
osal/window/os_log.c
Normal file
35
osal/window/os_log.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010 Rockchip Electronics S.LSI 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define LINE_SZ 1024
|
||||
|
||||
void os_log(const char* tag, const char* msg, va_list list)
|
||||
{
|
||||
char line[LINE_SZ] = {0};
|
||||
_snprintf(line, sizeof(line), "%s: %s", tag, msg);
|
||||
vfprintf(stdout, line, list);
|
||||
}
|
||||
|
||||
void os_err(const char* tag, const char* msg, va_list list)
|
||||
{
|
||||
char line[LINE_SZ] = {0};
|
||||
_snprintf(line, sizeof(line), "%s: %s", tag, msg);
|
||||
vfprintf(stderr, line, list);
|
||||
}
|
||||
|
Reference in New Issue
Block a user