[Other] Enable to hidden INFO/WARNING log informations (#1368)

* Enable to hidden INFO/WARNING log informations

* Fix build error

---------

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
This commit is contained in:
Jason
2023-02-20 17:24:12 +08:00
committed by GitHub
parent b6658b8094
commit dc5b4be7a9
5 changed files with 36 additions and 5 deletions

View File

@@ -43,6 +43,9 @@ namespace fastdeploy {
class FASTDEPLOY_DECL FDLogger {
public:
static bool enable_info;
static bool enable_warning;
FDLogger() {
line_ = "";
prefix_ = "[FastDeploy]";
@@ -90,11 +93,12 @@ FASTDEPLOY_DECL bool ReadBinaryFromFile(const std::string& file,
<< __REL_FILE__ << "(" << __LINE__ << ")::" << __FUNCTION__ << "\t"
#define FDWARNING \
FDLogger(true, "[WARNING]") \
FDLogger(fastdeploy::FDLogger::enable_warning, "[WARNING]") \
<< __REL_FILE__ << "(" << __LINE__ << ")::" << __FUNCTION__ << "\t"
#define FDINFO \
FDLogger(true, "[INFO]") << __REL_FILE__ << "(" << __LINE__ \
FDLogger(fastdeploy::FDLogger::enable_info, "[INFO]") \
<< __REL_FILE__ << "(" << __LINE__ \
<< ")::" << __FUNCTION__ << "\t"
#define FDASSERT(condition, format, ...) \
@@ -214,6 +218,10 @@ std::string Str(const std::vector<T>& shape) {
return oss.str();
}
/// Set behaviour of logging while using FastDeploy
FASTDEPLOY_DECL void SetLogger(bool enable_info = true,
bool enable_warning = true);
template <typename T>
void CalculateStatisInfo(const void* src_ptr, int size, double* mean,
double* max, double* min) {