diff --git a/src/base/application.cpp b/src/base/application.cpp index 3b5688f09..3d056e5ba 100644 --- a/src/base/application.cpp +++ b/src/base/application.cpp @@ -164,19 +164,23 @@ void Application::Messages::writelogendl() void Application::Messages::beginLogGroup(std::string title, int _loglevel /*=-99*/) { + // Add the current loglevel to the vector of loglevels + loglevels.push_back(loglevel); + // loglevel is a member of the Messages class. if (_loglevel != -99) { loglevel = _loglevel; } else { loglevel--; } + + // Add the title of the current logLevel to the vector of titles + loggroups.push_back(title); + if (loglevel <= 0) { return; } - // Add the current loglevel to the vector of loglevels - loglevels.push_back(loglevel); - // Add the title of the current logLevel to the vector of titles - loggroups.push_back(title); + // If we haven't started an XML tree for the log file, do so here if (xmllog == 0) { // The top of this tree will have a zero pointer. @@ -218,33 +222,31 @@ void Application::Messages::addLogEntry(std::string msg) void Application::Messages::endLogGroup(std::string title) { - if (loglevel <= 0) { - return; - } - AssertThrowMsg(current, "Application::Messages::endLogGroup", - "Error while ending a LogGroup. This is probably due to an unmatched" - " beginning and ending group"); - current = current->parent(); - AssertThrowMsg(current, "Application::Messages::endLogGroup", - "Error while ending a LogGroup. This is probably due to an unmatched" - " beginning and ending group"); - current = current->parent(); - // Get the loglevel of the previous level and get rid of - // vector entry in loglevels. - loglevel = loglevels.back(); - loglevels.pop_back(); - if (title != "" && title != loggroups.back()) { + if (title != "" && title != loggroups.back()) { writelog("Logfile error." "\n beginLogGroup: "+ loggroups.back()+ "\n endLogGroup: "+title+"\n"); write_logfile("logerror"); - } else if (loggroups.size() == 1) { - write_logfile(loggroups.back()+"_log"); - loggroups.clear(); - loglevels.clear(); - } else { - loggroups.pop_back(); } + + if (loggroups.empty()) { + write_logfile(loggroups.back()+"_log"); + } else if (loglevel > 0) { + AssertThrowMsg(current, "Application::Messages::endLogGroup", + "Error while ending a LogGroup. This is probably due to an unmatched" + " beginning and ending group"); + current = current->parent(); + AssertThrowMsg(current, "Application::Messages::endLogGroup", + "Error while ending a LogGroup. This is probably due to an unmatched" + " beginning and ending group"); + current = current->parent(); + // Get the loglevel of the previous level and get rid of + // vector entry in loglevels. + } + + loggroups.pop_back(); + loglevel = loglevels.back(); + loglevels.pop_back(); } void Application::Messages::write_logfile(std::string file) diff --git a/src/equil/ChemEquil.cpp b/src/equil/ChemEquil.cpp index f5a5a493b..28a0260ab 100644 --- a/src/equil/ChemEquil.cpp +++ b/src/equil/ChemEquil.cpp @@ -827,7 +827,7 @@ int ChemEquil::equilibrate(thermo_t& s, const char* XYstr, next: iter++; - if (iter > 1) { + if (iter > 1 && loglevel > 0) { endLogGroup("Iteration "+int2str(iter-1)); // iteration } if (loglevel > 0) { diff --git a/src/equil/vcs_MultiPhaseEquil.cpp b/src/equil/vcs_MultiPhaseEquil.cpp index 72fa6a48b..3b26d03a2 100644 --- a/src/equil/vcs_MultiPhaseEquil.cpp +++ b/src/equil/vcs_MultiPhaseEquil.cpp @@ -732,9 +732,7 @@ int vcs_MultiPhaseEquil::equilibrate_TP(int estimateEquil, } } } - if (loglevel > 0) { - endLogGroup(); - } + endLogGroup(); return iSuccess; } @@ -1656,9 +1654,8 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int } } } - if (loglevel > 0) { - endLogGroup(); - } + endLogGroup("vcs_MultiPhaseEquil::determine_PhaseStability"); + return iStable; } //====================================================================================================================