提交 c54247c2 编写于 作者: H Heisenberg

change the code under suggestions


Former-commit-id: e4bb750aa14b6405c6af434239f71037a7de2744
上级 a823d6e4
......@@ -6,7 +6,7 @@
TO_STANDARD_OUTPUT = false
SUBSECOND_PRECISION = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 200MB
MAX_LOG_FILE_SIZE = 10240 ##209715200 ## Throw log files away after 200MB
* DEBUG:
FILENAME = "@MILVUS_DB_PATH@/logs/milvus-%datetime{%H:%m}-debug.log"
ENABLED = true
......
......@@ -12,11 +12,67 @@
#include <string>
#include <libgen.h>
namespace zilliz {
namespace milvus {
namespace server {
int32_t InitLog(const std::string& log_config_file) {
namespace {
static int global_idx = 0;
static int debug_idx = 0;
static int warning_idx = 0;
static int trace_idx = 0;
static int error_idx = 0;
static int fatal_idx = 0;
}
// TODO(yzb) : change the easylogging library to get the log level from parameter rather than filename
void rolloutHandler(const char *filename, std::size_t size) {
char *dirc = strdup(filename);
char *basec = strdup(filename);
char *dir = dirname(dirc);
char *base = basename(basec);
std::string s(base);
std::stringstream ss;
std::string
list[] = {"\\", " ", "\'", "\"", "*", "\?", "{", "}", ";", "<", ">", "|", "^", "&", "$", "#", "!", "`", "~"};
std::string::size_type position;
for (auto substr : list) {
position = 0;
while ((position = s.find_first_of(substr, position)) != std::string::npos) {
s.insert(position, "\\");
position += 2;
}
}
int ret;
std::string m(std::string(dir) + "/" + s);
s = m;
if ((position = s.find("global")) != std::string::npos) {
s.append("." + std::to_string(++global_idx));
ret = rename(m.c_str(), s.c_str());
} else if ((position = s.find("debug")) != std::string::npos) {
s.append("." + std::to_string(++debug_idx));
ret = rename(m.c_str(), s.c_str());
} else if ((position = s.find("warning")) != std::string::npos) {
s.append("." + std::to_string(++warning_idx));
ret = rename(m.c_str(), s.c_str());
} else if ((position = s.find("trace")) != std::string::npos) {
s.append("." + std::to_string(++trace_idx));
ret = rename(m.c_str(), s.c_str());
} else if ((position = s.find("error")) != std::string::npos) {
s.append("." + std::to_string(++error_idx));
ret = rename(m.c_str(), s.c_str());
} else if ((position = s.find("fatal")) != std::string::npos) {
s.append("." + std::to_string(++fatal_idx));
ret = rename(m.c_str(), s.c_str());
} else {
s.append("." + std::to_string(++global_idx));
ret = rename(m.c_str(), s.c_str());
}
}
int32_t InitLog(const std::string &log_config_file) {
#if 0
ServerConfig &config = ServerConfig::GetInstance();
ConfigNode log_config = config.GetConfig(CONFIG_LOG);
......@@ -60,48 +116,6 @@ int32_t InitLog(const std::string& log_config_file) {
return 0;
}
// TODO(yzb) : change the easylogging library to get the log level from parameter rather than filename
void rolloutHandler(const char* filename, std::size_t size){
char *dirc = strdup(filename);
char *basec = strdup(filename);
char *dir = dirname(dirc);
char *base = basename(basec);
std::string s(base);
std::stringstream ss;
std::string list[] = {"\\", " ", "\'", "\"", "*", "\?", "{", "}", ";", "<", ">", "|", "^", "&", "$", "#", "!", "`", "~"};
std::string::size_type position;
for(auto substr : list){
position = 0;
while((position = s.find_first_of(substr, position)) != std::string::npos){
s.insert(position, "\\");
position += 2;
}
}
if((position = s.find("global")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++global_idx;
}
else if((position = s.find("debug")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++debug_idx;
}
else if((position = s.find("warning")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++warning_idx;
}
else if((position = s.find("trace")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++trace_idx;
}
else if((position = s.find("error")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++error_idx;
}
else if((position = s.find("fatal")) != std::string::npos){
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++fatal_idx;
}
else{
ss << "mv " << dir << "/" << s << " " << dir << "/" << s << "." << ++global_idx;
}
// std::cout << ss.str() << std::endl;
system(ss.str().c_str());
}
} // server
} // milvus
......
......@@ -11,18 +11,7 @@
namespace zilliz {
namespace milvus {
namespace server {
static unsigned global_idx = 0;
static unsigned debug_idx = 0;
static unsigned warning_idx = 0;
static unsigned trace_idx = 0;
static unsigned error_idx = 0;
static unsigned fatal_idx = 0;
int32_t InitLog(const std::string& log_config_file);
void rolloutHandler(const char* filename, std::size_t size);
inline std::string GetFileName(std::string filename) {
int pos = filename.find_last_of('/');
return filename.substr(pos + 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册