mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-03-15 18:40:57 +08:00
mk_log_printf改用vasprintf函数
This commit is contained in:
Submodule 3rdpart/ZLToolKit updated: ee7ae998aa...be74074d38
@@ -11,6 +11,7 @@
|
||||
#include "mk_util.h"
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include "Util/util.h"
|
||||
#include "Util/logger.h"
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
@@ -47,12 +48,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, ...) {
|
||||
assert(file && function && fmt);
|
||||
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
||||
va_list pArg;
|
||||
va_start(pArg, fmt);
|
||||
char buf[4096];
|
||||
auto n = vsnprintf(buf, sizeof(buf), fmt, pArg);
|
||||
buf[n] = '\0';
|
||||
va_end(pArg);
|
||||
info << buf;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char *str = nullptr;
|
||||
vasprintf(&str, fmt, ap);
|
||||
va_end(ap);
|
||||
info << str;
|
||||
free(str);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user