mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-09-26 21:15:53 +08:00
feat[mpp_log]: Add external callback support
Signed-off-by: Herman Chen <herman.chen@rock-chips.com> Change-Id: Ice375b1c9522442f403cf6eb1d1d2306e64b9b30
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#ifndef __MPP_LOG_H__
|
||||
#define __MPP_LOG_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "rk_type.h"
|
||||
#include "mpp_log_def.h"
|
||||
|
||||
@@ -88,6 +90,9 @@ void _mpp_log_l(int level, const char *tag, const char *fmt, const char *func, .
|
||||
void mpp_set_log_level(int level);
|
||||
int mpp_get_log_level(void);
|
||||
|
||||
typedef void (*MppLogCb)(void *ctx, int level, const char *tag, const char *fmt, const char *func, va_list args);
|
||||
int mpp_set_log_callback(void *ctx, MppLogCb cb);
|
||||
|
||||
/* deprecated function */
|
||||
void _mpp_log(const char *tag, const char *fmt, const char *func, ...);
|
||||
void _mpp_err(const char *tag, const char *fmt, const char *func, ...);
|
||||
|
@@ -17,7 +17,6 @@
|
||||
#define MODULE_TAG "mpp_log"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mpp_env.h"
|
||||
@@ -38,6 +37,8 @@ RK_U32 mpp_debug = 0;
|
||||
static const char *msg_log_warning = "log message is long\n";
|
||||
static const char *msg_log_nothing = "\n";
|
||||
static int mpp_log_level = MPP_LOG_INFO;
|
||||
static MppLogCb mpp_log_ext_cb = NULL;
|
||||
static void *mpp_log_ext_ctx = NULL;
|
||||
|
||||
static void __mpp_log(os_log_callback func, const char *tag, const char *fmt,
|
||||
const char *fname, va_list args)
|
||||
@@ -114,6 +115,13 @@ void _mpp_log_l(int level, const char *tag, const char *fmt, const char *fname,
|
||||
va_list args;
|
||||
int log_level;
|
||||
|
||||
if (mpp_log_ext_cb) {
|
||||
va_start(args, fname);
|
||||
mpp_log_ext_cb(mpp_log_ext_ctx, level, tag, fmt, fname, args);
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (level <= MPP_LOG_UNKNOWN || level >= MPP_LOG_SILENT)
|
||||
return;
|
||||
|
||||
@@ -154,6 +162,14 @@ int mpp_get_log_level(void)
|
||||
return level;
|
||||
}
|
||||
|
||||
int mpp_set_log_callback(void *ctx, MppLogCb cb)
|
||||
{
|
||||
mpp_log_ext_cb = cb;
|
||||
mpp_log_ext_ctx = ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user