|
@ -15,7 +15,7 @@ |
|
|
#include <sstream> |
|
|
#include <sstream> |
|
|
#include <exception> |
|
|
#include <exception> |
|
|
|
|
|
|
|
|
using namespace pEp::Adapter::pEpLog; |
|
|
//using namespace pEp::Adapter::pEpLog;
|
|
|
|
|
|
|
|
|
namespace pEp { |
|
|
namespace pEp { |
|
|
namespace PityTest11 { |
|
|
namespace PityTest11 { |
|
@ -23,6 +23,8 @@ namespace pEp { |
|
|
std::string PityUnit<T>::_global_root_dir = "./pitytest_data/"; |
|
|
std::string PityUnit<T>::_global_root_dir = "./pitytest_data/"; |
|
|
template<class T> |
|
|
template<class T> |
|
|
bool PityUnit<T>::debug_log_enabled = false; |
|
|
bool PityUnit<T>::debug_log_enabled = false; |
|
|
|
|
|
template<class T> |
|
|
|
|
|
int PityUnit<T>::procNodesCount = 0; |
|
|
|
|
|
|
|
|
// CONCSTRUCTORS
|
|
|
// CONCSTRUCTORS
|
|
|
template<class T> |
|
|
template<class T> |
|
@ -38,6 +40,15 @@ namespace pEp { |
|
|
logger_debug.set_instancename(getNodePath()); |
|
|
logger_debug.set_instancename(getNodePath()); |
|
|
if (!_isRootNode()) { |
|
|
if (!_isRootNode()) { |
|
|
parent->_addChildNode(*this); |
|
|
parent->_addChildNode(*this); |
|
|
|
|
|
// Inherit
|
|
|
|
|
|
procNodeNr = _parent->procNodeNr; |
|
|
|
|
|
//Or update if procNode
|
|
|
|
|
|
if (_isProcessNode()) { |
|
|
|
|
|
procNodesCount++; |
|
|
|
|
|
procNodeNr = procNodesCount; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
procNodeNr = procNodesCount; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -125,11 +136,11 @@ namespace pEp { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<class T> |
|
|
// template<class T>
|
|
|
void PityUnit<T>::setExecutionMode(ExecutionMode mode) |
|
|
// void PityUnit<T>::setExecutionMode(ExecutionMode mode)
|
|
|
{ |
|
|
// {
|
|
|
_exec_mode = mode; |
|
|
// _exec_mode = mode;
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
// static
|
|
|
// static
|
|
|
template<> |
|
|
template<> |
|
@ -254,14 +265,32 @@ namespace pEp { |
|
|
builder << getNodePathShort(); |
|
|
builder << getNodePathShort(); |
|
|
builder << "] - "; |
|
|
builder << "] - "; |
|
|
builder << msg; |
|
|
builder << msg; |
|
|
builder << std::endl; |
|
|
|
|
|
logRaw(builder.str()); |
|
|
logRaw(builder.str()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<class T> |
|
|
template<class T> |
|
|
void PityUnit<T>::logRaw(const std::string& msg) const |
|
|
void PityUnit<T>::logRaw(const std::string& msg) const |
|
|
{ |
|
|
{ |
|
|
std::cerr << msg << std::endl; |
|
|
Adapter::pEpLog::log(msg, termColor()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
|
void PityUnit<T>::logH1(const std::string& msg) const |
|
|
|
|
|
{ |
|
|
|
|
|
Adapter::pEpLog::logH1(msg, termColor()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
|
void PityUnit<T>::logH2(const std::string& msg) const |
|
|
|
|
|
{ |
|
|
|
|
|
Adapter::pEpLog::logH2(msg, termColor()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
|
void PityUnit<T>::logH3(const std::string& msg) const |
|
|
|
|
|
{ |
|
|
|
|
|
Adapter::pEpLog::logH3(msg, termColor()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -282,11 +311,11 @@ namespace pEp { |
|
|
_test_func(*this); |
|
|
_test_func(*this); |
|
|
logH3(_status_string("SUCCESS")); |
|
|
logH3(_status_string("SUCCESS")); |
|
|
} catch (const std::exception& e) { |
|
|
} catch (const std::exception& e) { |
|
|
log("reason: " + std::string(e.what())); |
|
|
logRaw("reason: " + std::string(e.what())); |
|
|
logH3(_status_string("FAILED")); |
|
|
logH3(_status_string("FAILED")); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
log("No function to execute"); |
|
|
logRaw("No function to execute"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -402,6 +431,36 @@ namespace pEp { |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
|
Utils::Color PityUnit<T>::colForProcNodeNr(int procNodeNr) const |
|
|
|
|
|
{ |
|
|
|
|
|
switch (procNodeNr) { |
|
|
|
|
|
case 0: |
|
|
|
|
|
return Utils::Color::WHITE; |
|
|
|
|
|
case 1: |
|
|
|
|
|
return Utils::Color::CYAN; |
|
|
|
|
|
case 2: |
|
|
|
|
|
return Utils::Color::MAGENTA; |
|
|
|
|
|
case 3: |
|
|
|
|
|
return Utils::Color::BLUE; |
|
|
|
|
|
case 4: |
|
|
|
|
|
return Utils::Color::GREEN; |
|
|
|
|
|
case 5: |
|
|
|
|
|
return Utils::Color::YELLOW; |
|
|
|
|
|
case 6: |
|
|
|
|
|
return Utils::Color::RED; |
|
|
|
|
|
default: |
|
|
|
|
|
return Utils::Color::WHITE; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<class T> |
|
|
|
|
|
Utils::Color PityUnit<T>::termColor() const |
|
|
|
|
|
{ |
|
|
|
|
|
return colForProcNodeNr(procNodeNr); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
template<class T> |
|
|
template<class T> |
|
|
void PityUnit<T>::_ensureDir(const std::string& path) const |
|
|
void PityUnit<T>::_ensureDir(const std::string& path) const |
|
|
{ |
|
|
{ |
|
|