Skip to content

Commit

Permalink
#30: add helper function to get per-node log level
Browse files Browse the repository at this point in the history
  • Loading branch information
mistafunk committed Aug 23, 2020
1 parent 0391a03 commit eafc023
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/palladio/NodeParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,31 @@ constexpr const int CHANGED = 1;

} // namespace

namespace CommonNodeParams {

prt::LogLevel getLogLevel(const OP_Node* node, fpreal t) {
const auto ord = node->evalInt(LOG_LEVEL.getToken(), 0, t);
switch (ord) {
case 1:
return prt::LOG_DEBUG;
case 2:
return prt::LOG_INFO;
case 3:
return prt::LOG_WARNING;
case 4:
return prt::LOG_ERROR;
case 5:
return prt::LOG_FATAL;
case 6:
return prt::LOG_NO;
default:
break;
}
return logging::getDefaultLogLevel();
};

} // namespace CommonNodeParams

namespace AssignNodeParams {

/**
Expand Down
4 changes: 4 additions & 0 deletions src/palladio/NodeParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "PRM/PRM_Shared.h"
#include "PRM/PRM_SpareData.h"

#include "prt/LogLevel.h"

// clang-format off
#include "BoostRedirect.h"
#include PLD_BOOST_INCLUDE(/filesystem/path.hpp)
Expand All @@ -46,6 +48,8 @@ static PRM_ChoiceList logLevelMenu((PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE
const size_t DEFAULT_LOG_LEVEL_ORDINAL = 0;
static PRM_Default DEFAULT_LOG_LEVEL(0, LOG_LEVEL_TOKENS[DEFAULT_LOG_LEVEL_ORDINAL]);

prt::LogLevel getLogLevel(const OP_Node* node, fpreal t);

} // namespace CommonNodeParams

namespace AssignNodeParams {
Expand Down

0 comments on commit eafc023

Please sign in to comment.