Browse Source

log optimize

pull/1215/head
liyihan2@huawei.com 5 years ago
parent
commit
9198f2a651
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      ge/analyzer/analyzer.cc

+ 8
- 8
ge/analyzer/analyzer.cc View File

@@ -103,7 +103,7 @@ ge::Status Analyzer::Initialize() {
// Initialize file
string real_path = RealPath(kFilePath.c_str());
if (real_path.empty()) {
GELOGE(FAILED, "File path is invalid.");
GELOGE(FAILED, "[Check][AnalyzerFilePath] File path:%s is invalid!", real_path.cstr());
return FAILED;
}
json_file_name_ = real_path + "/" + kAnalyzeFile;
@@ -155,12 +155,12 @@ std::shared_ptr<GraphInfo> Analyzer::GetJsonObject(uint64_t session_id, uint64_t
std::lock_guard<std::recursive_mutex> lg(mutex_);
auto iter = graph_infos_.find(session_id);
if (iter == graph_infos_.end()) {
GELOGE(PARAM_INVALID, "session_id:%lu does not exist!", session_id);
GELOGE(PARAM_INVALID, "[Check][Session_id]session_id:%lu does not exist!", session_id);
return nullptr;
} else {
auto iter1 = (iter->second).find(graph_id);
if (iter1 == (iter->second).end()) {
GELOGE(PARAM_INVALID, "graph_id:%lu does not exist!", graph_id);
GELOGE(PARAM_INVALID, "[Check][Graph_id]graph_id:%lu does not exist!", graph_id);
return nullptr;
}
GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id);
@@ -186,11 +186,11 @@ ge::Status Analyzer::CreateAnalyzerFile() {
std::lock_guard<std::mutex> lg(file_mutex_);
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority);
if (fd < 0) {
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str());
GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzerFile]Fail to open the file: %s.", json_file_name_.c_str());
return INTERNAL_ERROR;
}
if (close(fd) != 0) {
GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", json_file_name_.c_str());
GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzerFile]Fail to close the file: %s.", json_file_name_.c_str());
return INTERNAL_ERROR;
}
is_json_file_create_ = true;
@@ -211,7 +211,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
std::lock_guard<std::mutex> lg(file_mutex_);
json_file_.open(json_file_name_, std::ios::app);
if (!json_file_.is_open()) {
GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str());
GELOGE(FAILED, "[Check][AnalyzerFile]analyzer file does not exist[%s]", json_file_name_.c_str());
return PARAM_INVALID;
}

@@ -221,7 +221,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
try {
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl;
} catch (nlohmann::detail::type_error &e) {
GELOGE(FAILED, "analyzer file [%s] failed because [%s]", json_file_name_.c_str(), e.what());
GELOGE(FAILED, "[FindReason][AnalyzerFile]analyzer file [%s] failed because [%s]", json_file_name_.c_str(), e.what());
ret_failed = true;
}
json_file_.close();
@@ -241,7 +241,7 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
GE_CHECK_NOTNULL(graph_info);
auto status = SaveOpInfo(desc, data_info, graph_info);
if (status != SUCCESS) {
GELOGE(status, "save op info failed!");
GELOGE(status, "[Check][SaveOpInfo]save op info:pnode:%s desc:%s graph_info:%s failed!", pnode.cstr(), desc.cstr(), graph_info.cstr());
return FAILED;
}
// create json file


Loading…
Cancel
Save