mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
整理日志接口
This commit is contained in:
parent
5d9f05669e
commit
a8e61010cf
@ -1 +1 @@
|
||||
Subproject commit be74074d382a43e970de05fe88f412e5a05e38d6
|
||||
Subproject commit ff70ca32dec78534633f6c7f586550e2e8004d1d
|
@ -65,12 +65,12 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len);
|
||||
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...);
|
||||
|
||||
// 以下宏可以替换printf使用
|
||||
#define log_trace(fmt,...) mk_log_printf(0,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
|
||||
#define log_debug(fmt,...) mk_log_printf(1,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
|
||||
#define log_info(fmt,...) mk_log_printf(2,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
|
||||
#define log_warn(fmt,...) mk_log_printf(3,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
|
||||
#define log_error(fmt,...) mk_log_printf(4,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
|
||||
#define log_printf(lev, fmt, ...) mk_log_printf(lev, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
||||
#define log_trace(...) log_printf(0,##__VA_ARGS__)
|
||||
#define log_debug(...) log_printf(1, ##__VA_ARGS__)
|
||||
#define log_info(...) log_printf(2, ##__VA_ARGS__)
|
||||
#define log_warn(...) log_printf(3, ##__VA_ARGS__)
|
||||
#define log_error(...) log_printf(4, ##__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "mk_util.h"
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include "Util/util.h"
|
||||
#include "Util/logger.h"
|
||||
@ -46,14 +45,9 @@ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len){
|
||||
}
|
||||
|
||||
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...) {
|
||||
assert(file && function && fmt);
|
||||
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char *str = nullptr;
|
||||
vasprintf(&str, fmt, ap);
|
||||
toolkit::printLog(getLogger(), level, file, function, line, fmt, ap);
|
||||
va_end(ap);
|
||||
info << str;
|
||||
free(str);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user