mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-29 18:38:44 +08:00
add log util
Former-commit-id: 4ef6aa4f14c95a9635aa9747b47cb3c3ad002a65
This commit is contained in:
parent
3927781cca
commit
49b4614b89
@ -25,6 +25,7 @@ add_executable(vecwise_engine_server
|
||||
${server_files}
|
||||
${utils_files}
|
||||
${wrapper_files}
|
||||
${VECWISE_THIRD_PARTY_BUILD}/include/easylogging++.cc
|
||||
)
|
||||
|
||||
set(dependency_libs
|
||||
|
@ -10,9 +10,13 @@
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <signal.h>
|
||||
#include <easylogging++.h>
|
||||
|
||||
#include "utils/SignalUtil.h"
|
||||
#include "utils/CommonUtil.h"
|
||||
#include "utils/LogUtil.h"
|
||||
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
void print_help(const std::string &app_name);
|
||||
|
||||
@ -20,7 +24,9 @@ using namespace zilliz::vecwise;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
server::CommonUtil::PrintInfo("Vecwise engine server start");
|
||||
zilliz::vecwise::server::InitLog();
|
||||
|
||||
printf("Vecwise engine server start...\n");
|
||||
|
||||
// zilliz::lib::gpu::InitMemoryAllocator();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "CommonUtil.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/sysinfo.h>
|
||||
@ -31,13 +32,13 @@ namespace server {
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
void CommonUtil::PrintInfo(const std::string& info){
|
||||
// SERVER_LOG_INFO << info;
|
||||
std::cout << info << std::endl;
|
||||
SERVER_LOG_INFO << info;
|
||||
// std::cout << info << std::endl;
|
||||
}
|
||||
|
||||
void CommonUtil::PrintError(const std::string& info){
|
||||
// SERVER_LOG_ERROR << info;
|
||||
std::cout << info << std::endl;
|
||||
SERVER_LOG_ERROR << info;
|
||||
// std::cout << info << std::endl;
|
||||
}
|
||||
|
||||
bool CommonUtil::GetSystemMemInfo(unsigned long &totalMem, unsigned long &freeMem) {
|
||||
|
41
cpp/src/utils/Log.h
Normal file
41
cpp/src/utils/Log.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential.
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "Error.h"
|
||||
#include <easylogging++.h>
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
#define SERVER_DOMAIN_NAME "[SERVER] "
|
||||
#define SERVER_ERROR_TEXT "SERVER Error:"
|
||||
|
||||
#define SERVER_LOG_TRACE LOG(TRACE) << SERVER_DOMAIN_NAME
|
||||
#define SERVER_LOG_DEBUG LOG(DEBUG) << SERVER_DOMAIN_NAME
|
||||
#define SERVER_LOG_INFO LOG(INFO) << SERVER_DOMAIN_NAME
|
||||
#define SERVER_LOG_WARNING LOG(WARNING) << SERVER_DOMAIN_NAME
|
||||
#define SERVER_LOG_ERROR LOG(ERROR) << SERVER_DOMAIN_NAME
|
||||
#define SERVER_LOG_FATAL LOG(FATAL) << SERVER_DOMAIN_NAME
|
||||
|
||||
#define SERVER_ERROR(error) \
|
||||
({ \
|
||||
SERVER_LOG_ERROR << SERVER_ERROR_TEXT << error; \
|
||||
(error); \
|
||||
})
|
||||
|
||||
#define SERVER_CHECK(func) \
|
||||
{ \
|
||||
zilliz::vecwise::server::ServerError error = func; \
|
||||
if (error != zilliz::vecwise::server::SERVER_SUCCESS) { \
|
||||
return SERVER_ERROR(error); \
|
||||
} \
|
||||
} \
|
||||
|
||||
} // namespace sql
|
||||
} // namespace zilliz
|
||||
} // namespace server
|
24
cpp/src/utils/LogUtil.cpp
Normal file
24
cpp/src/utils/LogUtil.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "LogUtil.h"
|
||||
|
||||
#include <easylogging++.h>
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
int32_t InitLog() {
|
||||
el::Configurations conf("../../conf/vecwise_engine_log.conf");
|
||||
el::Loggers::reconfigureAllLoggers(conf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // server
|
||||
} // vecwise
|
||||
} // zilliz
|
31
cpp/src/utils/LogUtil.h
Normal file
31
cpp/src/utils/LogUtil.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential.
|
||||
******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
int32_t InitLog();
|
||||
|
||||
inline std::string GetFileName(std::string filename) {
|
||||
int pos = filename.find_last_of('/');
|
||||
return filename.substr(pos + 1);
|
||||
}
|
||||
|
||||
#define SHOW_LOCATION
|
||||
#ifdef SHOW_LOCATION
|
||||
#define LOCATION_INFO "[" << zilliz::sql::server::GetFileName(__FILE__) << ":" << __LINE__ << "] "
|
||||
#else
|
||||
#define LOCATION_INFO ""
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
#include "SignalUtil.h"
|
||||
#include "CommonUtil.h"
|
||||
#include "server/Server.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
|
Loading…
Reference in New Issue
Block a user