ZLMediaKit/api/include/mk_util.h

79 lines
2.4 KiB
C++
Raw Normal View History

/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MK_UTIL_H
#define MK_UTIL_H
#include <stdlib.h>
#include "mk_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* @return 使free
*/
API_EXPORT char* API_CALL mk_util_get_exe_path();
/**
*
* @param relative_path ,null
* @return 使free
*/
2020-02-21 11:35:53 +08:00
API_EXPORT char* API_CALL mk_util_get_exe_dir(const char *relative_path);
/**
* unix标准的系统时间戳
* @return
*/
2020-02-21 11:35:53 +08:00
API_EXPORT uint64_t API_CALL mk_util_get_current_millisecond();
/**
*
* @param fmt %Y-%m-%d %H:%M:%S
* @return 使free
*/
2020-02-21 11:35:53 +08:00
API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt);
/**
*
* @param buf
* @param len
* @return 使free
*/
2020-02-21 11:35:53 +08:00
API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len);
///////////////////////////////////////////日志/////////////////////////////////////////////
/**
*
* @param level ,0~4
* @param file __FILE__
* @param function __FUNCTION__
* @param line __LINE__
* @param fmt printf类型的格式控制字符串
* @param ...
*/
API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char *function, int line, const char *fmt, ...);
// 以下宏可以替换printf使用
2021-10-18 16:02:14 +08:00
#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
}
#endif
#endif //MK_UTIL_H