diff --git a/src/PityUnit.hh b/src/PityUnit.hh index 16d44cd..cc2f5b5 100644 --- a/src/PityUnit.hh +++ b/src/PityUnit.hh @@ -58,6 +58,7 @@ namespace pEp { // logging service void log(const std::string& msg) const; + void logRaw(const std::string& msg) const; // internal logging static bool debug_log_enabled; @@ -88,14 +89,10 @@ namespace pEp { std::string _normalizeName(std::string name) const; std::string _status_string(const std::string& msg) const; - // TODO + // Dirs void _ensureDir(const std::string& path) const; void _recreateDir(const std::string& path ) const; - void _data_dir_delete(); - void _data_dir_create(); - void _data_dir_recreate(); - // Fields const std::string _name; const PityUnit* _parent; //nullptr if RootUnit diff --git a/src/PityUnit.hxx b/src/PityUnit.hxx index 075bbe4..a9086c3 100644 --- a/src/PityUnit.hxx +++ b/src/PityUnit.hxx @@ -148,6 +148,14 @@ namespace pEp { template void PityUnit::_init() const { + logH1("PityTest Starting..."); + logRaw("RootNode: " + getNodePathShort()); + logRaw("GlobalRootDir: " + getGlobalRootDir()); + logRaw("\nTestTree"); + logRaw("--------"); + logRaw(to_string()); + + logH3("INIT"); _ensureDir(getGlobalRootDir()); _recreateDir(processDir()); if (!_children.empty()) { @@ -155,17 +163,16 @@ namespace pEp { _recreateDir(child.second.processDir()); } } + logH3("INIT DONE"); } template void PityUnit::run() const { pEpLogClass("called"); - _init(); // caller is never nullptr if called by another PityUnit if (_isRootNode()) { - logH1("Starting PityUnit from node: " + getNodePathShort()); - std::cout << to_string() << std::endl; + _init(); } // Execute in fork and wait here until process ends @@ -237,7 +244,6 @@ namespace pEp { } } - //Well, ok, lets just add some little convenience logging service in here, too template void PityUnit::log(const std::string& msg) const { @@ -249,9 +255,16 @@ namespace pEp { builder << "] - "; builder << msg; builder << std::endl; - std::cout << builder.str(); + logRaw(builder.str()); } + template + void PityUnit::logRaw(const std::string& msg) const + { + std::cerr << msg << std::endl; + } + + // PRIVATE --------------------------------------------------------------------------------- template @@ -393,7 +406,7 @@ namespace pEp { void PityUnit::_ensureDir(const std::string& path) const { if (!Utils::path_exists(path)) { - log("creating dir:" + path); + logRaw("creating dir:" + path); Utils::dir_create(path); } } @@ -403,40 +416,17 @@ namespace pEp { { if (Utils::path_exists(path)) { try { - log("deleting dir:" + path); + logRaw("deleting dir:" + path); Utils::path_delete_all(path); } catch (const std::exception& e) { - log("PityUnit: - could not delete data dir: " + getGlobalRootDir()); + logRaw("PityUnit: - could not delete data dir: " + getGlobalRootDir()); } } - log("creating dir:" + path); + logRaw("creating dir:" + path); Utils::dir_create(path); } - template - void PityUnit::_data_dir_create() - { - // Utils::dir_create(dataDir()); - log("creating dir:" + getGlobalRootDir()); - } - - template - void PityUnit::_data_dir_delete() - { - try { - // Utils::path_delete_all(getGlobalRootDir()); - } catch (const std::exception& e) { - log("DistTest: - could not delete data dir: " + getGlobalRootDir()); - } - } - - template - void PityUnit::_data_dir_recreate() - { - _data_dir_delete(); - _data_dir_create(); - }; } // namespace PityTest11 } // namespace pEp