Skip to content

Commit

Permalink
Give log categories full names
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Nov 14, 2016
1 parent c26746f commit f2e948c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
18 changes: 9 additions & 9 deletions SimulationRuntime/cpp/Core/SimController/SimManager.cpp
Expand Up @@ -265,25 +265,25 @@ void SimManager::runSimulation()
#endif
try
{
LOGGER_WRITE("SimManager: Start simulation at t = " + to_string(_tStart), LC_SOLV, LL_INFO);
LOGGER_WRITE("SimManager: Start simulation at t = " + to_string(_tStart), LC_SOLVER, LL_INFO);
runSingleProcess();
// Measure time; Output SimInfos
ISolver::SOLVERSTATUS status = _solver->getSolverStatus();
if ((status & ISolver::DONE) || (status & ISolver::USER_STOP))
{
//LOGGER_WRITE("SimManager: Simulation done at t = " + to_string(_tEnd), LC_SOLV, LL_INFO);
//LOGGER_WRITE("SimManager: Simulation done at t = " + to_string(_tEnd), LC_SOLVER, LL_INFO);
writeProperties();
}
}
catch (std::exception & ex)
{
LOGGER_WRITE("SimManager: Simulation stopped with errors before t = " +
to_string(_tEnd), LC_SOLV, LL_ERROR);
LOGGER_WRITE("SimManager: " + string(ex.what()), LC_SOLV, LL_ERROR);
to_string(_tEnd), LC_SOLVER, LL_ERROR);
LOGGER_WRITE("SimManager: " + string(ex.what()), LC_SOLVER, LL_ERROR);
writeProperties();
// rethrow with suppress depending on logger setting to not appear twice
throw ModelicaSimulationError(SIMMANAGER, ex.what(), "",
LOGGER_IS_SET(LC_SOLV, LL_ERROR));
LOGGER_IS_SET(LC_SOLVER, LL_ERROR));
}
#ifdef RUNTIME_PROFILING
if (MeasureTime::getInstance() != NULL)
Expand All @@ -302,14 +302,14 @@ void SimManager::stopSimulation()
void SimManager::writeProperties()
{
// declaration for Logging
std::pair<LogCategory, LogLevel> logM = Logger::getLogMode(LC_SOLV, LL_INFO);
std::pair<LogCategory, LogLevel> logM = Logger::getLogMode(LC_SOLVER, LL_INFO);

LOGGER_WRITE_TUPLE("SimManager: Simulation stop time: " + to_string(_tEnd), logM);
//LOGGER_WRITE("Rechenzeit in Sekunden: " + to_string>(_tClockEnd-_tClockStart), logM);

LOGGER_WRITE_BEGIN("Simulation info from solver:", LC_SOLV, LL_INFO);
LOGGER_WRITE_BEGIN("Simulation info from solver:", LC_SOLVER, LL_INFO);
_solver->writeSimulationInfo();
LOGGER_WRITE_END(LC_SOLV, LL_INFO);
LOGGER_WRITE_END(LC_SOLVER, LL_INFO);
/*
// Zeit
if(_settings->_globalSettings->bEndlessSim)
Expand Down Expand Up @@ -566,7 +566,7 @@ void SimManager::runSingleProcess()

/* Logs temporarily disabled
BOOST_LOG_SEV(simmgr_lg::get(), simmgr_normal) <<"Run single process." ; */
LOGGER_WRITE("SimManager: Run single process",LC_SOLV,LL_DEBUG);
LOGGER_WRITE("SimManager: Run single process", LC_SOLVER, LL_DEBUG);

memset(_timeEventCounter, 0, _dimtimeevent * sizeof(int));
computeEndTimes(tStopsSub);
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Core/System/ContinuousEvents.cpp
Expand Up @@ -103,7 +103,7 @@ bool ContinuousEvents::startEventIteration(bool& state_vars_reinitialized)
bool crestart =false;
if (dim > 0)
{
LOGGER_WRITE_VECTOR("conditions", _conditions1, dim, LC_EVT, LL_DEBUG);
LOGGER_WRITE_VECTOR("conditions", _conditions1, dim, LC_EVENTS, LL_DEBUG);
crestart = !std::equal(_conditions1, _conditions1 + dim, _conditions0);
}
//check for event clocks
Expand Down
8 changes: 4 additions & 4 deletions SimulationRuntime/cpp/Core/Utils/extension/logger.cpp
Expand Up @@ -83,13 +83,13 @@ std::string Logger::getCategory(LogCategory cat) const
return "nls";
case(LC_LS):
return "ls";
case(LC_SOLV):
case(LC_SOLVER):
return "solver";
case(LC_OUT):
case(LC_OUTPUT):
return "output";
case(LC_EVT):
case(LC_EVENTS):
return "events";
case(LC_MOD):
case(LC_MODEL):
return "model";
case(LC_OTHER):
default:
Expand Down
Expand Up @@ -229,7 +229,7 @@ void MeasureTime::writeToJson()
{
if((*data)[i] == NULL)
{
LOGGER_WRITE("Skipped a measured block in '" + block->first + "' because it is null.", LC_OUT, LL_ERROR);
LOGGER_WRITE("Skipped a measured block in '" + block->first + "' because it is null.", LC_OUTPUT, LL_ERROR);
continue;
}
tmpS = (*data)[i]->serializeToJson();
Expand Down
Expand Up @@ -25,7 +25,7 @@ using std::string;

#include <vector>

enum LogCategory {LC_INIT = 0, LC_NLS = 1, LC_LS = 2, LC_SOLV = 3, LC_OUT = 4, LC_EVT = 5, LC_OTHER = 6, LC_MOD = 7};
enum LogCategory {LC_INIT = 0, LC_NLS = 1, LC_LS = 2, LC_SOLVER = 3, LC_OUTPUT = 4, LC_EVENTS = 5, LC_OTHER = 6, LC_MODEL = 7};
enum LogLevel {LL_ERROR = 0, LL_WARNING = 1, LL_INFO = 2, LL_DEBUG = 3};
enum LogFormat {LF_TXT = 0, LF_XML = 1};
enum LogOMEdit {LOG_EVENTS = 0, LOG_INIT, LOG_LS, LOG_NLS, LOG_SOLVER, LOG_STATS};
Expand Down
16 changes: 8 additions & 8 deletions SimulationRuntime/cpp/SimCoreFactory/OMCFactory/OMCFactory.cpp
Expand Up @@ -74,9 +74,9 @@ static LogSettings initializeLogger(const po::variables_map& vm)
{
map<string, LogCategory> logCatMap = MAP_LIST_OF
"init", LC_INIT MAP_LIST_SEP "nls", LC_NLS MAP_LIST_SEP
"ls", LC_LS MAP_LIST_SEP "solver", LC_SOLV MAP_LIST_SEP
"output", LC_OUT MAP_LIST_SEP "events", LC_EVT MAP_LIST_SEP
"model", LC_MOD MAP_LIST_SEP "other", LC_OTHER MAP_LIST_END;
"ls", LC_LS MAP_LIST_SEP "solver", LC_SOLVER MAP_LIST_SEP
"output", LC_OUTPUT MAP_LIST_SEP "events", LC_EVENTS MAP_LIST_SEP
"model", LC_MODEL MAP_LIST_SEP "other", LC_OTHER MAP_LIST_END;
map<string, LogLevel> logLvlMap = MAP_LIST_OF
"error", LL_ERROR MAP_LIST_SEP "warning", LL_WARNING MAP_LIST_SEP
"info", LL_INFO MAP_LIST_SEP "debug", LL_DEBUG MAP_LIST_END;
Expand Down Expand Up @@ -109,7 +109,7 @@ static LogSettings initializeLogger(const po::variables_map& vm)
}
switch (logOMEdit) {
case LOG_EVENTS:
logSettings.modes[LC_EVT] = LL_DEBUG;
logSettings.modes[LC_EVENTS] = LL_DEBUG;
break;
case LOG_INIT:
logSettings.modes[LC_INIT] = LL_DEBUG;
Expand All @@ -121,11 +121,11 @@ static LogSettings initializeLogger(const po::variables_map& vm)
logSettings.modes[LC_NLS] = LL_DEBUG;
break;
case LOG_SOLVER:
logSettings.modes[LC_SOLV] = LL_DEBUG;
logSettings.modes[LC_SOLVER] = LL_DEBUG;
//case LOG_STATS:
default:
if (logSettings.modes[LC_SOLV] < LL_INFO)
logSettings.modes[LC_SOLV] = LL_INFO;
if (logSettings.modes[LC_SOLVER] < LL_INFO)
logSettings.modes[LC_SOLVER] = LL_INFO;
}
}
}
Expand All @@ -150,7 +150,7 @@ static LogSettings initializeLogger(const po::variables_map& vm)
}
}

if (vm.count("warn-all")) {
if (vm.count("warn-all") && vm["warn-all"].as<bool>()) {
for (int i = 0; i < logSettings.modes.size(); i++)
if (logSettings.modes[i] < LL_WARNING)
logSettings.modes[i] = LL_WARNING;
Expand Down
14 changes: 7 additions & 7 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -322,7 +322,7 @@ void Cvode::initialize()

_cvode_initialized = true;

LOGGER_WRITE("Cvode: initialized",LC_SOLV,LL_DEBUG);
LOGGER_WRITE("Cvode: initialized", LC_SOLVER, LL_DEBUG);
}
}

Expand Down Expand Up @@ -962,12 +962,12 @@ void Cvode::writeSimulationInfo()

flag = CVodeGetNonlinSolvStats(_cvodeMem, &nni, &ncfn);

LOGGER_WRITE("Cvode: number steps = " + to_string(nst), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: function evaluations 'f' = " + to_string(nfe), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: linear solver setups 'nsetups' = " + to_string(nsetups), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: nonlinear iterations 'nni' = " + to_string(nni), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: convergence failures 'ncfn' = " + to_string(ncfn), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: number of evaluateODE calls 'eODE' = " + to_string(_numberOfOdeEvaluations), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: number steps = " + to_string(nst), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: function evaluations 'f' = " + to_string(nfe), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: linear solver setups 'nsetups' = " + to_string(nsetups), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: nonlinear iterations 'nni' = " + to_string(nni), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: convergence failures 'ncfn' = " + to_string(ncfn), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: number of evaluateODE calls 'eODE' = " + to_string(_numberOfOdeEvaluations), LC_SOLVER, LL_INFO);

//// Solver
//outputStream << "\nSolver: " << getName()
Expand Down
14 changes: 7 additions & 7 deletions SimulationRuntime/cpp/Solver/IDA/IDA.cpp
@@ -1,5 +1,5 @@
#include <Core/ModelicaDefine.h>
#include <Core/Modelica.h>
#include <Core/Modelica.h>
#include <Solver/IDA/IDA.h>
#include <Core/Math/Functions.h>

Expand Down Expand Up @@ -1073,12 +1073,12 @@ void Ida::writeSimulationInfo()

flag = IDAGetNonlinSolvStats(_idaMem, &nni, &ncfn);

LOGGER_WRITE("Cvode: number steps = " + to_string(nst), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: function evaluations 'f' = " + to_string(nfe), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: error test failures 'netf' = " + to_string(netfS), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: linear solver setups 'nsetups' = " + to_string(nsetups), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: nonlinear iterations 'nni' = " + to_string(nni), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: convergence failures 'ncfn' = " + to_string(ncfn), LC_SOLV, LL_INFO);
LOGGER_WRITE("Cvode: number steps = " + to_string(nst), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: function evaluations 'f' = " + to_string(nfe), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: error test failures 'netf' = " + to_string(netfS), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: linear solver setups 'nsetups' = " + to_string(nsetups), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: nonlinear iterations 'nni' = " + to_string(nni), LC_SOLVER, LL_INFO);
LOGGER_WRITE("Cvode: convergence failures 'ncfn' = " + to_string(ncfn), LC_SOLVER, LL_INFO);
}

int Ida::check_flag(void *flagvalue, const char *funcname, int opt)
Expand Down

0 comments on commit f2e948c

Please sign in to comment.