mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 03:31:45 +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 "mk_util.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "Util/util.h"
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
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, ...) {
|
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);
|
assert(file && function && fmt);
|
||||||
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
LogContextCapturer info(Logger::Instance(), (LogLevel) level, file, function, line);
|
||||||
va_list pArg;
|
va_list ap;
|
||||||
va_start(pArg, fmt);
|
va_start(ap, fmt);
|
||||||
char buf[4096];
|
char *str = nullptr;
|
||||||
auto n = vsnprintf(buf, sizeof(buf), fmt, pArg);
|
vasprintf(&str, fmt, ap);
|
||||||
buf[n] = '\0';
|
va_end(ap);
|
||||||
va_end(pArg);
|
info << str;
|
||||||
info << buf;
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user