mirror of https://github.com/milvus-io/milvus.git
MS-119 The problem of combining the log files
Former-commit-id: b3ade33ab3348ef3108c60faa62e8e3239ad5a00pull/191/head
parent
5e41d5c09a
commit
a641bb4bb3
|
@ -29,6 +29,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
|||
- MS-492 - Drop index failed if index have been created with index_type: FLAT
|
||||
- MS-493 - Knowhere unittest crash
|
||||
- MS-453 - GPU search error when nprobe set more than 1024
|
||||
- MS-119 - The problem of combining the log files
|
||||
|
||||
## Improvement
|
||||
- MS-327 - Clean code for milvus
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#include <easylogging++.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <string>
|
||||
#include <libgen.h>
|
||||
|
||||
namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace server {
|
||||
|
@ -50,11 +53,55 @@ int32_t InitLog(const std::string& log_config_file) {
|
|||
#else
|
||||
el::Configurations conf(log_config_file);
|
||||
#endif
|
||||
|
||||
el::Loggers::reconfigureAllLoggers(conf);
|
||||
|
||||
el::Loggers::addFlag(el::LoggingFlag::StrictLogFileSizeCheck);
|
||||
el::Helpers::installPreRollOutCallback(rolloutHandler);
|
||||
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
|
||||
|
|
|
@ -12,8 +12,17 @@ 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);
|
||||
|
|
Loading…
Reference in New Issue