diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 8b1f866..e66a301 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -14,7 +14,7 @@ jobs: name: "Test Python bindings" strategy: matrix: - on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ] + on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-15' ] python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ] runs-on: ${{ matrix.on }} diff --git a/.gitignore b/.gitignore index 194cd58..8a4f4c0 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,6 @@ dist/** # debug information files *.dwo -**.DS_Store \ No newline at end of file +**.DS_Store + +*build* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ebe30f..32704c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,11 +57,18 @@ FetchContent_Declare( GIT_TAG v1.8.1 ) +FetchContent_Declare( + calf + GIT_REPOSITORY https://github.com/High-Performance-IO/calf.git + GIT_TAG v0.1.1 +) + +# JSONCONS build flags set(JSONCONS_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(JSONCONS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(JSONCONS_BUILD_FUZZERS OFF CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(jsoncons tomlplusplus) +FetchContent_MakeAvailable(jsoncons tomlplusplus calf) if (BUILD_PYTHON_BINDINGS) FetchContent_Declare( @@ -129,24 +136,33 @@ set(CAPIO_CL_HEADERS capiocl.hpp) # Library target add_library(libcapio_cl STATIC ${CAPIO_SRC} ${CAPIO_CL_HEADERS}) + target_include_directories(libcapio_cl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${jsoncons_SOURCE_DIR}/include ${CAPIOCL_JSON_SCHEMAS_DIRECTORY} ${TOMLPLUSPLUS_SOURCE_DIR}/include + ${CALF_SOURCE_DIR} ) target_link_libraries(libcapio_cl PUBLIC) target_link_libraries(libcapio_cl PRIVATE - tomlplusplus::tomlplusplus -) + tomlplusplus::tomlplusplus) find_library(LIBANL anl) -if(LIBANL) +if (LIBANL) target_link_libraries(libcapio_cl PRIVATE ${LIBANL}) endif () +##################################### +# set CALF logger component name +##################################### +calf_enable_log(libcapio_cl $,ON,OFF>) +calf_set_component(libcapio_cl "capiocl") +calf_set_default_log_dir(libcapio_cl "./capiocl_logs") +target_include_directories(libcapio_cl PRIVATE ${CALF_SOURCE_DIR}) + ##################################### # Install rules ##################################### @@ -202,7 +218,7 @@ if (CAPIO_CL_BUILD_TESTS) CURL::libcurl ) - if(LIBANL) + if (LIBANL) target_link_libraries(CAPIO_CL_tests PRIVATE ${LIBANL}) endif () @@ -296,11 +312,11 @@ if (ENABLE_COVERAGE_PIPELINE) COMMAND ${LCOV_BIN} --remove ${COVERAGE_INFO} - "*jsoncons*" - "/usr/include/*" - "*googletest*" - "*tests/*" - ${COVERAGE_REMOVE_PATTERNS} + "*jsoncons*" + "/usr/include/*" + "*googletest*" + "*tests/*" + ${COVERAGE_REMOVE_PATTERNS} --ignore-errors unused --ignore-errors inconsistent --output-file ${COVERAGE_INFO} diff --git a/capiocl/monitor.h b/capiocl/monitor.h index 662ab89..32bdc7b 100644 --- a/capiocl/monitor.h +++ b/capiocl/monitor.h @@ -2,6 +2,7 @@ #define CAPIO_CL_MONITOR_H #include +#include #include #include #include @@ -12,17 +13,15 @@ #include "configuration.h" -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 1024 -#endif - /// @brief Namespace containing the CAPIO-CL Monitor components namespace capiocl::monitor { +/// @brief Buffer size used to store a null-terminated host name. +inline constexpr std::size_t HOSTNAME_BUFFER_SIZE = 1024; + +/// @brief Maximum path storage used in multicast monitor messages. +inline constexpr std::size_t PATH_BUFFER_SIZE = 4096; + /// @brief Constant value for when a home node is not found static const std::string NO_HOME_NODE = ""; @@ -84,7 +83,7 @@ class MonitorInterface { /** * @brief hostname of the current instance */ - mutable char _hostname[HOST_NAME_MAX] = {0}; + mutable char _hostname[HOSTNAME_BUFFER_SIZE] = {0}; public: /** @@ -118,7 +117,7 @@ class MonitorInterface { * @param path * @return the home node responsible for the given path */ - virtual const std::string &getHomeNode(const std::filesystem::path &path) const; + virtual std::string getHomeNode(const std::filesystem::path &path) const; }; /** @@ -133,7 +132,7 @@ class MonitorInterface { */ class MulticastMonitor final : public MonitorInterface { - static constexpr int MESSAGE_SIZE = (2 + PATH_MAX + PATH_MAX); ///< Max network message size. + static constexpr int MESSAGE_SIZE = 2 + (2 * PATH_BUFFER_SIZE); ///< Max network message size. /** * @brief Background threads used to listen for commit messages and for home nodes. @@ -229,7 +228,7 @@ class MulticastMonitor final : public MonitorInterface { bool isCommitted(const std::filesystem::path &path) const override; void setCommitted(const std::filesystem::path &path) const override; void setHomeNode(const std::filesystem::path &path) const override; - const std::string &getHomeNode(const std::filesystem::path &path) const override; + std::string getHomeNode(const std::filesystem::path &path) const override; }; /** @@ -288,7 +287,7 @@ class FileSystemMonitor final : public MonitorInterface { bool isCommitted(const std::filesystem::path &path) const override; void setCommitted(const std::filesystem::path &path) const override; void setHomeNode(const std::filesystem::path &path) const override; - const std::string &getHomeNode(const std::filesystem::path &path) const override; + std::string getHomeNode(const std::filesystem::path &path) const override; }; /** @@ -344,4 +343,4 @@ class Monitor { }; } // namespace capiocl::monitor -#endif // CAPIO_CL_MONITOR_H \ No newline at end of file +#endif // CAPIO_CL_MONITOR_H diff --git a/capiocl/printer.h b/capiocl/printer.h deleted file mode 100644 index 1069bf6..0000000 --- a/capiocl/printer.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CAPIO_CL_PRINTER_H -#define CAPIO_CL_PRINTER_H -#include -#include - -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 1024 -#endif - -/// @brief Namespace containing the CAPIO-CL print utilities -namespace capiocl::printer { - -/// @brief CLI print constant -constexpr char CLI_LEVEL_INFO[] = "[\033[1;32mCAPIO-CL\033[0m"; -/// @brief CLI print constant -constexpr char CLI_LEVEL_WARNING[] = "[\033[1;33mCAPIO-CL\033[0m"; -/// @brief CLI print constant -constexpr char CLI_LEVEL_ERROR[] = "[\033[1;31mCAPIO-CL\033[0m"; -/// @brief CLI print constant -constexpr char CLI_LEVEL_JSON[] = "[\033[1;34mCAPIO-CL\033[0m"; - -/** - * Print a message to standard out. Used to log messages related to the CAPIO-CL Engine - * @param message_type Type of message to print. - * @param message_line - */ -inline void print(const std::string &message_type = "", const std::string &message_line = "") { - static std::string *node_name = nullptr; - if (node_name == nullptr) { - node_name = new std::string(HOST_NAME_MAX, ' '); // LCOV_EXCL_LINE - gethostname(node_name->data(), HOST_NAME_MAX); - } - if (message_type.empty()) { - std::cout << std::endl; - } else { - std::cout << message_type << " " << node_name->c_str() << "] " << message_line << std::endl - << std::flush; - } -} -} // namespace capiocl::printer - -#endif // CAPIO_CL_PRINTER_H \ No newline at end of file diff --git a/src/Engine.cpp b/src/Engine.cpp index d6951fc..321441d 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -3,19 +3,26 @@ #include #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/configuration.h" #include "capiocl/engine.h" #include "capiocl/monitor.h" -#include "capiocl/printer.h" /// @brief Class to implement a shared mutex lock guard template class shared_lock_guard { public: /// @brief Constructor: acquire semaphore shared - explicit shared_lock_guard(SharedMutex &m) : mutex_(m) { mutex_.lock_shared(); } + explicit shared_lock_guard(SharedMutex &m) : mutex_(m) { + START_LOG(calf_current_tid(), "call()"); + mutex_.lock_shared(); + } /// @brief Destructor: release resources - ~shared_lock_guard() { mutex_.unlock_shared(); } + ~shared_lock_guard() { + START_LOG(calf_current_tid(), "call()"); + mutex_.unlock_shared(); + } shared_lock_guard(const shared_lock_guard &) = delete; shared_lock_guard &operator=(const shared_lock_guard &) = delete; @@ -26,47 +33,49 @@ template class shared_lock_guard { }; void capiocl::engine::Engine::print() const { - + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(workflow_name); // First message - printer::print(printer::CLI_LEVEL_JSON, ""); - printer::print(printer::CLI_LEVEL_JSON, "Composition of expected CAPIO FS: "); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, " "); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Composition of expected CAPIO FS: "); // Table header lines - printer::print(printer::CLI_LEVEL_JSON, "*" + std::string(134, '=') + "*"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "*%s*", std::string(134, '=').c_str()); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str()); - printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, ' ') + "|"); - - { - std::ostringstream oss; - oss << "| Parsed configuration file for workflow: \033[1;36m" << workflow_name - << std::setw(94 - workflow_name.length()) << "\033[0m |"; - printer::print(printer::CLI_LEVEL_JSON, oss.str()); - } + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, + "| Parsed configuration file for workflow: \033[1;36m %s%s \033[0m |", + workflow_name.c_str(), std::string(86 - workflow_name.length(), ' ').c_str()); - printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, ' ') + "|"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str()); - std::string msg = "| File color legend: \033[48;5;034m \033[0m File stored in memory"; - msg += std::string(82, ' ') + "|"; - printer::print(printer::CLI_LEVEL_JSON, msg); + CALF_PRINT_COLOR( + CALF_CLI_LEVEL_INFO, + "| File color legend: \033[48;5;034m \033[0m File stored in memory%s|", + std::string(82, ' ').c_str()); - printer::print( - printer::CLI_LEVEL_JSON, // LCOV_EXCL_LINE - "| \033[48;5;172m \033[0m File stored on file system" + - std::string(77, ' ') + "|"); + CALF_PRINT_COLOR( + CALF_CLI_LEVEL_INFO, + "| \033[48;5;172m \033[0m File stored on file system%s|", + std::string(77, ' ').c_str()); - printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, '=') + "|"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str()); - std::string line = "|======|===================|===================|===================="; - line += "|====================|============|===========|=========|==========|"; - printer::print(printer::CLI_LEVEL_JSON, line); + CALF_PRINT_COLOR( + CALF_CLI_LEVEL_INFO, "|%s|%s|%s|%s|%s|%s|%s|%s|%s|", std::string(6, '=').c_str(), + std::string(19, '=').c_str(), std::string(19, '=').c_str(), std::string(20, '=').c_str(), + std::string(20, '=').c_str(), std::string(12, '=').c_str(), std::string(11, '=').c_str(), + std::string(9, '=').c_str(), std::string(10, '=').c_str()); - line = "| Kind | Filename | Producer step | Consumer step | "; - line += "Commit Rule | Fire Rule | Permanent | Exclude | n_files |"; - printer::print(printer::CLI_LEVEL_JSON, line); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, + "| Kind | Filename | Producer step | Consumer step | " + "Commit Rule | Fire Rule | Permanent | Exclude | n_files |"); - line = "|======|===================|===================|====================|========"; - line += "============|============|===========|=========|==========|"; - printer::print(printer::CLI_LEVEL_JSON, line); + CALF_PRINT_COLOR( + CALF_CLI_LEVEL_INFO, "|%s|%s|%s|%s|%s|%s|%s|%s|%s|", std::string(6, '=').c_str(), + std::string(19, '=').c_str(), std::string(19, '=').c_str(), std::string(20, '=').c_str(), + std::string(20, '=').c_str(), std::string(12, '=').c_str(), std::string(11, '=').c_str(), + std::string(9, '=').c_str(), std::string(10, '=').c_str()); // Iterate over _locations for (auto &itm : _capio_cl_entries) { @@ -136,24 +145,29 @@ void capiocl::engine::Engine::print() const { line << std::setfill(' ') << std::setw(10) << "|" << std::setw(11) << "|"; } - printer::print(printer::CLI_LEVEL_JSON, line.str()); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "%s", line.str().c_str()); } - printer::print(printer::CLI_LEVEL_JSON, "*" + std::string(134, '~') + "*"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "*%s*", std::string(134, '~').c_str()); } - printer::print(printer::CLI_LEVEL_JSON, ""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, " "); } capiocl::engine::Engine::Engine(const bool use_default_settings) { + START_LOG(calf_current_tid(), "call()"); node_name = std::string(1024, '\0'); gethostname(node_name.data(), node_name.size()); node_name.resize(std::strlen(node_name.c_str())); if (const char *_wf_name = std::getenv("WORKFLOW_NAME"); _wf_name != nullptr) { this->workflow_name = _wf_name; + LOG("selected workflow name=%s source=environment node=%s", workflow_name.c_str(), + node_name.c_str()); } else { this->workflow_name = CAPIO_CL_DEFAULT_WF_NAME; + LOG("selected workflow name=%s source=default node=%s", workflow_name.c_str(), + node_name.c_str()); } if (use_default_settings) { @@ -162,6 +176,7 @@ capiocl::engine::Engine::Engine(const bool use_default_settings) { } void capiocl::engine::Engine::_newFile(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -198,6 +213,10 @@ void capiocl::engine::Engine::_newFile(const std::filesystem::path &path) const } else { entry.store_in_memory = store_all_in_memory; } + LOG("creating entry path=%s source=%s commit_rule=%s fire_rule=%s memory=%d", + path.string().c_str(), matchSize > 0 ? matchKey.c_str() : "defaults", + entry.commit_rule.c_str(), entry.fire_rule.c_str(), + static_cast(entry.store_in_memory)); _capio_cl_entries.emplace(path, std::move(entry)); this->compute_directory_entry_count(path); } @@ -205,11 +224,14 @@ void capiocl::engine::Engine::_newFile(const std::filesystem::path &path) const void capiocl::engine::Engine::compute_directory_entry_count( const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (const auto parent = path.parent_path(); !parent.empty()) { if (const auto &entry = _capio_cl_entries.find(parent); entry != _capio_cl_entries.end()) { if (entry->second.enable_directory_count_update) { entry->second.directory_children_count++; entry->second.is_file = false; + LOG("updated directory path=%s children=%ld", parent.string().c_str(), + entry->second.directory_children_count); } else { return; } @@ -220,6 +242,7 @@ void capiocl::engine::Engine::compute_directory_entry_count( } bool capiocl::engine::Engine::contains(const std::filesystem::path &file) const { + START_LOG(calf_current_tid(), "call()"); shared_lock_guard slg(_shared_mutex); return std::any_of(_capio_cl_entries.begin(), _capio_cl_entries.end(), [&](auto const &entry) { return fnmatch(entry.first.c_str(), file.c_str(), FNM_NOESCAPE) == 0; @@ -227,6 +250,7 @@ bool capiocl::engine::Engine::contains(const std::filesystem::path &file) const } size_t capiocl::engine::Engine::size() const { + START_LOG(calf_current_tid(), "call()"); shared_lock_guard slg(_shared_mutex); return this->_capio_cl_entries.size(); } @@ -236,7 +260,7 @@ void capiocl::engine::Engine::add(std::filesystem::path &path, std::vector &dependencies) { - + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -251,26 +275,34 @@ void capiocl::engine::Engine::add(std::filesystem::path &path, std::vector(entry.permanent), static_cast(entry.excluded)); } void capiocl::engine::Engine::add(const std::filesystem::path &path, const CapioCLEntry &entry) const { - + START_LOG(calf_current_tid(), "call()"); std::lock_guard lg(_shared_mutex); if (_capio_cl_entries.find(path) == _capio_cl_entries.end()) { _capio_cl_entries[path] = entry; + LOG("inserted entry path=%s", path.string().c_str()); } else { _capio_cl_entries[path] += entry; + LOG("merged entry path=%s", path.string().c_str()); } } void capiocl::engine::Engine::newFile(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::lock_guard lg(_shared_mutex); this->_newFile(path); } long capiocl::engine::Engine::getDirectoryFileCount(const std::filesystem::path &path) const { - + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return 0; } @@ -286,7 +318,7 @@ long capiocl::engine::Engine::getDirectoryFileCount(const std::filesystem::path void capiocl::engine::Engine::addProducer(const std::filesystem::path &path, std::string &producer) { - + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -300,6 +332,8 @@ void capiocl::engine::Engine::addProducer(const std::filesystem::path &path, auto &vec = itm->second.producers; if (std::find(vec.begin(), vec.end(), producer) == vec.end()) { vec.emplace_back(producer); + LOG("added producer path=%s producer=%s count=%zu", path.string().c_str(), + producer.c_str(), vec.size()); return; } else { return; @@ -313,6 +347,7 @@ void capiocl::engine::Engine::addProducer(const std::filesystem::path &path, void capiocl::engine::Engine::addConsumer(const std::filesystem::path &path, std::string &consumer) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -324,6 +359,8 @@ void capiocl::engine::Engine::addConsumer(const std::filesystem::path &path, auto &vec = itm->second.consumers; if (std::find(vec.begin(), vec.end(), consumer) == vec.end()) { vec.emplace_back(consumer); + LOG("added consumer path=%s consumer=%s count=%zu", path.string().c_str(), + consumer.c_str(), vec.size()); } return; } @@ -335,6 +372,7 @@ void capiocl::engine::Engine::addConsumer(const std::filesystem::path &path, void capiocl::engine::Engine::addFileDependency(const std::filesystem::path &path, std::filesystem::path &file_dependency) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -345,6 +383,8 @@ void capiocl::engine::Engine::addFileDependency(const std::filesystem::path &pat auto &vec = itm->second.file_dependencies; if (std::find(vec.begin(), vec.end(), file_dependency) == vec.end()) { vec.emplace_back(file_dependency); + LOG("added dependency path=%s dependency=%s count=%zu", path.string().c_str(), + file_dependency.string().c_str(), vec.size()); } return; } @@ -356,6 +396,7 @@ void capiocl::engine::Engine::addFileDependency(const std::filesystem::path &pat void capiocl::engine::Engine::setCommitRule(const std::filesystem::path &path, const std::string &commit_rule) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -364,6 +405,10 @@ void capiocl::engine::Engine::setCommitRule(const std::filesystem::path &path, { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.commit_rule != commit) { + LOG("changing commit rule path=%s old=%s new=%s", path.string().c_str(), + itm->second.commit_rule.c_str(), commit.c_str()); + } itm->second.commit_rule = commit; return; } @@ -376,6 +421,7 @@ void capiocl::engine::Engine::setCommitRule(const std::filesystem::path &path, } std::string capiocl::engine::Engine::getCommitRule(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return commitRules::ON_TERMINATION; } @@ -396,6 +442,7 @@ std::string capiocl::engine::Engine::getCommitRule(const std::filesystem::path & } std::string capiocl::engine::Engine::getFireRule(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return fireRules::NO_UPDATE; } @@ -417,6 +464,7 @@ std::string capiocl::engine::Engine::getFireRule(const std::filesystem::path &pa void capiocl::engine::Engine::setFireRule(const std::filesystem::path &path, const std::string &fire_rule) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -426,6 +474,10 @@ void capiocl::engine::Engine::setFireRule(const std::filesystem::path &path, { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.fire_rule != fire) { + LOG("changing fire rule path=%s old=%s new=%s", path.string().c_str(), + itm->second.fire_rule.c_str(), fire.c_str()); + } itm->second.fire_rule = fire; return; } @@ -436,6 +488,7 @@ void capiocl::engine::Engine::setFireRule(const std::filesystem::path &path, } bool capiocl::engine::Engine::isFirable(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -455,6 +508,7 @@ bool capiocl::engine::Engine::isFirable(const std::filesystem::path &path) const } void capiocl::engine::Engine::setPermanent(const std::filesystem::path &path, bool value) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -462,6 +516,10 @@ void capiocl::engine::Engine::setPermanent(const std::filesystem::path &path, bo { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.permanent != value) { + LOG("changing permanent path=%s old=%d new=%d", path.string().c_str(), + static_cast(itm->second.permanent), static_cast(value)); + } itm->second.permanent = value; return; } @@ -471,6 +529,7 @@ void capiocl::engine::Engine::setPermanent(const std::filesystem::path &path, bo } bool capiocl::engine::Engine::isPermanent(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -490,14 +549,18 @@ bool capiocl::engine::Engine::isPermanent(const std::filesystem::path &path) con } bool capiocl::engine::Engine::isCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); return monitor.isCommitted(path); } void capiocl::engine::Engine::setCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); monitor.setCommitted(path); + LOG("dispatched committed update path=%s", path.string().c_str()); } std::vector capiocl::engine::Engine::getPaths() const { + START_LOG(calf_current_tid(), "call()"); shared_lock_guard slg(_shared_mutex); std::vector paths; @@ -508,12 +571,17 @@ std::vector capiocl::engine::Engine::getPaths() const { } void capiocl::engine::Engine::setExclude(const std::filesystem::path &path, const bool value) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.excluded != value) { + LOG("changing excluded path=%s old=%d new=%d", path.string().c_str(), + static_cast(itm->second.excluded), static_cast(value)); + } itm->second.excluded = value; return; } @@ -523,6 +591,7 @@ void capiocl::engine::Engine::setExclude(const std::filesystem::path &path, cons } void capiocl::engine::Engine::setDirectory(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -530,6 +599,9 @@ void capiocl::engine::Engine::setDirectory(const std::filesystem::path &path) { { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.is_file) { + LOG("changing entry type path=%s old=file new=directory", path.string().c_str()); + } itm->second.is_file = false; return; } @@ -539,6 +611,7 @@ void capiocl::engine::Engine::setDirectory(const std::filesystem::path &path) { } void capiocl::engine::Engine::setFile(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -546,6 +619,9 @@ void capiocl::engine::Engine::setFile(const std::filesystem::path &path) { { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (!itm->second.is_file) { + LOG("changing entry type path=%s old=directory new=file", path.string().c_str()); + } itm->second.is_file = true; return; } @@ -555,6 +631,7 @@ void capiocl::engine::Engine::setFile(const std::filesystem::path &path) { } bool capiocl::engine::Engine::isFile(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -574,6 +651,7 @@ bool capiocl::engine::Engine::isFile(const std::filesystem::path &path) const { } bool capiocl::engine::Engine::isDirectory(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -582,6 +660,7 @@ bool capiocl::engine::Engine::isDirectory(const std::filesystem::path &path) con void capiocl::engine::Engine::setCommitedCloseNumber(const std::filesystem::path &path, const long num) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -589,6 +668,10 @@ void capiocl::engine::Engine::setCommitedCloseNumber(const std::filesystem::path { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.commit_on_close_count != num) { + LOG("changing commit-close count path=%s old=%ld new=%ld", path.string().c_str(), + itm->second.commit_on_close_count, num); + } itm->second.commit_on_close_count = num; return; } @@ -599,6 +682,7 @@ void capiocl::engine::Engine::setCommitedCloseNumber(const std::filesystem::path void capiocl::engine::Engine::setDirectoryFileCount(const std::filesystem::path &path, const long num) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -613,6 +697,8 @@ void capiocl::engine::Engine::setDirectoryFileCount(const std::filesystem::path if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { itm->second.directory_children_count = num; itm->second.enable_directory_count_update = false; + LOG("fixed directory count path=%s count=%ld automatic_updates=disabled", + path.string().c_str(), num); return; } this->_newFile(path); @@ -621,16 +707,19 @@ void capiocl::engine::Engine::setDirectoryFileCount(const std::filesystem::path } void capiocl::engine::Engine::remove(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm == _capio_cl_entries.end()) { return; } _capio_cl_entries.erase(path); + LOG("removed entry path=%s", path.string().c_str()); } std::vector capiocl::engine::Engine::getConsumers(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { @@ -641,6 +730,7 @@ capiocl::engine::Engine::getConsumers(const std::filesystem::path &path) const { bool capiocl::engine::Engine::isConsumer(const std::filesystem::path &path, const std::string &app_name) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -652,6 +742,8 @@ bool capiocl::engine::Engine::isConsumer(const std::filesystem::path &path, if (fnmatch(pattern.c_str(), path.c_str(), FNM_NOESCAPE) == 0) { const auto &consumers = entry.consumers; if (std::find(consumers.begin(), consumers.end(), app_name) != consumers.end()) { + LOG("consumer matched path=%s pattern=%s application=%s", path.string().c_str(), + pattern.c_str(), app_name.c_str()); return true; } } @@ -667,6 +759,7 @@ bool capiocl::engine::Engine::isConsumer(const std::filesystem::path &path, std::vector capiocl::engine::Engine::getProducers(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return {}; } @@ -688,6 +781,7 @@ capiocl::engine::Engine::getProducers(const std::filesystem::path &path) const { bool capiocl::engine::Engine::isProducer(const std::filesystem::path &path, const std::string &app_name) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -698,6 +792,8 @@ bool capiocl::engine::Engine::isProducer(const std::filesystem::path &path, if (fnmatch(pattern.c_str(), path.c_str(), FNM_NOESCAPE) == 0) { const auto &producers = entry.producers; if (std::find(producers.begin(), producers.end(), app_name) != producers.end()) { + LOG("producer matched path=%s pattern=%s application=%s", path.string().c_str(), + pattern.c_str(), app_name.c_str()); return true; } } @@ -713,6 +809,7 @@ bool capiocl::engine::Engine::isProducer(const std::filesystem::path &path, void capiocl::engine::Engine::setFileDeps(const std::filesystem::path &path, const std::vector &dependencies) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -730,6 +827,8 @@ void capiocl::engine::Engine::setFileDeps(const std::filesystem::path &path, if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { itm->second.file_dependencies = dependencies; + LOG("replaced dependencies path=%s count=%zu", path.string().c_str(), + dependencies.size()); return; } this->_newFile(path); @@ -738,6 +837,7 @@ void capiocl::engine::Engine::setFileDeps(const std::filesystem::path &path, } long capiocl::engine::Engine::getCommitCloseCount(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return 0; } @@ -758,6 +858,7 @@ long capiocl::engine::Engine::getCommitCloseCount(const std::filesystem::path &p std::vector capiocl::engine::Engine::getCommitOnFileDependencies(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); shared_lock_guard slg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { @@ -767,6 +868,7 @@ capiocl::engine::Engine::getCommitOnFileDependencies(const std::filesystem::path } void capiocl::engine::Engine::setStoreFileInMemory(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } @@ -775,6 +877,9 @@ void capiocl::engine::Engine::setStoreFileInMemory(const std::filesystem::path & std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (!itm->second.store_in_memory) { + LOG("changing storage path=%s target=memory", path.string().c_str()); + } itm->second.store_in_memory = true; return; } @@ -784,6 +889,7 @@ void capiocl::engine::Engine::setStoreFileInMemory(const std::filesystem::path & } void capiocl::engine::Engine::setAllStoreInMemory() { + START_LOG(calf_current_tid(), "call()"); { std::lock_guard lg(_shared_mutex); this->store_all_in_memory = true; @@ -793,25 +899,35 @@ void capiocl::engine::Engine::setAllStoreInMemory() { for (const auto &path : paths) { this->setStoreFileInMemory(path); } + LOG("enabled global memory storage updated_entries=%zu", paths.size()); } void capiocl::engine::Engine::setWorkflowName(const std::string &name) { + START_LOG(calf_current_tid(), "call()"); std::lock_guard lg(_shared_mutex); + if (this->workflow_name != name) { + LOG("changing workflow name old=%s new=%s", this->workflow_name.c_str(), name.c_str()); + } this->workflow_name = name; } const std::string &capiocl::engine::Engine::getWorkflowName() const { + START_LOG(calf_current_tid(), "call()"); shared_lock_guard slg(_shared_mutex); return this->workflow_name; } void capiocl::engine::Engine::setStoreFileInFileSystem(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return; } { std::lock_guard lg(_shared_mutex); if (const auto itm = _capio_cl_entries.find(path); itm != _capio_cl_entries.end()) { + if (itm->second.store_in_memory) { + LOG("changing storage path=%s target=filesystem", path.string().c_str()); + } itm->second.store_in_memory = false; return; } @@ -821,6 +937,7 @@ void capiocl::engine::Engine::setStoreFileInFileSystem(const std::filesystem::pa } bool capiocl::engine::Engine::isStoredInMemory(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -840,6 +957,7 @@ bool capiocl::engine::Engine::isStoredInMemory(const std::filesystem::path &path } std::vector capiocl::engine::Engine::getFileToStoreInMemory() const { + START_LOG(calf_current_tid(), "call()"); std::vector files; shared_lock_guard slg(_shared_mutex); @@ -855,14 +973,18 @@ std::vector capiocl::engine::Engine::getFileToStoreInMemory() const std::set capiocl::engine::Engine::getHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); return monitor.getHomeNode(path); } void capiocl::engine::Engine::setHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); monitor.setHomeNode(path); + LOG("dispatched home-node update path=%s node=%s", path.string().c_str(), node_name.c_str()); } bool capiocl::engine::Engine::isExcluded(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); if (path.empty()) { return true; } @@ -881,6 +1003,7 @@ bool capiocl::engine::Engine::isExcluded(const std::filesystem::path &path) cons } bool capiocl::engine::Engine::operator==(const Engine &other) const { + START_LOG(calf_current_tid(), "call()"); const auto &other_entries = other._capio_cl_entries; if (this->_capio_cl_entries.size() != other_entries.size()) { @@ -899,7 +1022,10 @@ bool capiocl::engine::Engine::operator==(const Engine &other) const { return true; } void capiocl::engine::Engine::loadConfiguration(const std::string &path) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(workflow_name); configuration.load(path); + LOG("loaded engine configuration path=%s", path.c_str()); std::string multicast_monitor_enabled, fs_monitor_enabled; @@ -907,39 +1033,50 @@ void capiocl::engine::Engine::loadConfiguration(const std::string &path) { configuration.getParameter("monitor.mcast.enabled", &multicast_monitor_enabled); } catch (...) { multicast_monitor_enabled = "false"; + LOG("configuration fallback key=monitor.mcast.enabled value=false"); } if (multicast_monitor_enabled == "true") { monitor.registerMonitorBackend(new monitor::MulticastMonitor(configuration)); + LOG("registered monitor backend=multicast"); } else { - printer::print(printer::CLI_LEVEL_WARNING, "Skipping registration of MulticastMonitor"); + LOG("skipped monitor backend=multicast reason=disabled"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Skipping registration of MulticastMonitor"); } try { configuration.getParameter("monitor.filesystem.enabled", &fs_monitor_enabled); } catch (...) { fs_monitor_enabled = "false"; + LOG("configuration fallback key=monitor.filesystem.enabled value=false"); } if (fs_monitor_enabled == "true") { monitor.registerMonitorBackend(new monitor::FileSystemMonitor()); + LOG("registered monitor backend=filesystem"); } else { - printer::print(printer::CLI_LEVEL_WARNING, "Skipping registration of FileSystemMonitor"); + LOG("skipped monitor backend=filesystem reason=disabled"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Skipping registration of FileSystemMonitor"); } } void capiocl::engine::Engine::useDefaultConfiguration() { + START_LOG(calf_current_tid(), "call()"); configuration.loadDefaults(); // TODO: add a vector with registered instances of backends to avoid multiple instantiations monitor.registerMonitorBackend(new monitor::MulticastMonitor(configuration)); monitor.registerMonitorBackend(new monitor::FileSystemMonitor()); + LOG("loaded default configuration monitor_backends=multicast,filesystem"); } void capiocl::engine::Engine::startApiServer() { + START_LOG(calf_current_tid(), "call()"); webapi_server = std::make_unique(this, configuration); + LOG("started API server"); } capiocl::engine::CapioCLEntry capiocl::engine::CapioCLEntry::fromJson(const std::string &in) { + START_LOG(calf_current_tid(), "call()"); jsoncons::json j = jsoncons::json::parse(in); CapioCLEntry entry; @@ -970,10 +1107,14 @@ capiocl::engine::CapioCLEntry capiocl::engine::CapioCLEntry::fromJson(const std: entry.excluded = j.get_value_or("excluded", entry.excluded); entry.is_file = j.get_value_or("is_file", entry.is_file); + LOG("decoded entry producers=%zu consumers=%zu dependencies=%zu commit_rule=%s fire_rule=%s", + entry.producers.size(), entry.consumers.size(), entry.file_dependencies.size(), + entry.commit_rule.c_str(), entry.fire_rule.c_str()); return entry; } std::string capiocl::engine::CapioCLEntry::toJson() const { + START_LOG(calf_current_tid(), "call()"); jsoncons::json j; j["producers"] = producers; j["consumers"] = consumers; @@ -998,6 +1139,7 @@ std::string capiocl::engine::CapioCLEntry::toJson() const { } capiocl::engine::CapioCLEntry &capiocl::engine::CapioCLEntry::operator+=(const CapioCLEntry &rhs) { + START_LOG(calf_current_tid(), "call()"); auto merge_vec = [](std::vector &dest, const std::vector &src) { dest.insert(dest.end(), src.begin(), src.end()); }; @@ -1024,13 +1166,14 @@ capiocl::engine::CapioCLEntry &capiocl::engine::CapioCLEntry::operator+=(const C } capiocl::engine::CapioCLEntry capiocl::engine::CapioCLEntry::operator+(const CapioCLEntry &rhs) { + START_LOG(calf_current_tid(), "call()"); CapioCLEntry result = *this; result += rhs; return result; } bool capiocl::engine::CapioCLEntry::operator==(const CapioCLEntry &other) { - + START_LOG(calf_current_tid(), "call()"); if (this->commit_rule != other.commit_rule || this->fire_rule != other.fire_rule || this->permanent != other.permanent || this->excluded != other.excluded || this->is_file != other.is_file || @@ -1080,5 +1223,6 @@ bool capiocl::engine::CapioCLEntry::operator==(const CapioCLEntry &other) { } bool capiocl::engine::CapioCLEntry::operator!=(const CapioCLEntry &other) { + START_LOG(calf_current_tid(), "call()"); return !(*this == other); -} \ No newline at end of file +} diff --git a/src/Monitor.cpp b/src/Monitor.cpp index 75e9f89..c742f3a 100644 --- a/src/Monitor.cpp +++ b/src/Monitor.cpp @@ -1,34 +1,45 @@ #include "capiocl/monitor.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" -#include "capiocl/printer.h" capiocl::monitor::MonitorException::MonitorException(const std::string &msg) : message(msg) { - printer::print(printer::CLI_LEVEL_ERROR, msg); + START_LOG(calf_current_tid(), "call()"); + LOG("monitor error message=%s", msg.c_str()); + std::cerr << msg << std::endl; } bool capiocl::monitor::Monitor::isCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); return std::any_of(interfaces.begin(), interfaces.end(), [&path](const auto &interface) { return interface->isCommitted(path); }); } void capiocl::monitor::Monitor::setCommitted(std::filesystem::path path) const { + START_LOG(calf_current_tid(), "call()"); + LOG("setting committed path=%s backends=%zu", path.string().c_str(), interfaces.size()); std::for_each(interfaces.begin(), interfaces.end(), [&path](const auto &interface) { interface->setCommitted(path); }); } void capiocl::monitor::Monitor::registerMonitorBackend(const MonitorInterface *interface) { + START_LOG(calf_current_tid(), "call()"); interfaces.emplace_back(interface); + LOG("registered monitor backend total=%zu", interfaces.size()); } + void capiocl::monitor::Monitor::setHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); + LOG("setting home node path=%s backends=%zu", path.string().c_str(), interfaces.size()); std::for_each(interfaces.begin(), interfaces.end(), [&path](const auto &interface) { interface->setHomeNode(path); }); } std::set capiocl::monitor::Monitor::getHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::set home_nodes; for (const auto &interface : interfaces) { - const auto &node = interface->getHomeNode(path); + const auto node = interface->getHomeNode(path); if (node == NO_HOME_NODE) { continue; } @@ -38,7 +49,8 @@ capiocl::monitor::Monitor::getHomeNode(const std::filesystem::path &path) const } capiocl::monitor::Monitor::~Monitor() { + START_LOG(calf_current_tid(), "call()"); for (const auto &interface : interfaces) { delete interface; } -} \ No newline at end of file +} diff --git a/src/Parser.cpp b/src/Parser.cpp index cc612ea..5af41a7 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -1,22 +1,28 @@ #include #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/engine.h" #include "capiocl/parser.h" -#include "capiocl/printer.h" capiocl::parser::ParserException::ParserException(const std::string &msg) : message(msg) { - printer::print(printer::CLI_LEVEL_ERROR, msg); + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", msg.c_str()); } jsoncons::jsonschema::json_schema capiocl::parser::Parser::loadSchema(const char *data) { + START_LOG(calf_current_tid(), "call()"); return jsoncons::jsonschema::make_json_schema(jsoncons::json::parse(data)); } std::filesystem::path capiocl::parser::Parser::resolve(std::filesystem::path path, const std::filesystem::path &prefix) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(""); if (prefix.empty()) { return path; } @@ -25,20 +31,23 @@ std::filesystem::path capiocl::parser::Parser::resolve(std::filesystem::path pat return path; } - auto resolved = prefix / path; - const auto msg = "Path : " + path.string() + " IS RELATIVE! Resolved to: " + resolved.string(); - printer::print(printer::CLI_LEVEL_WARNING, msg); + auto resolved = prefix / path; + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Path %s IS RELATIVE! Resolved to: %s", path.c_str(), + resolved.c_str()); return resolved; } void capiocl::parser::Parser::validate_json(const jsoncons::json &doc, const char *str_schema) { + START_LOG(calf_current_tid(), "call()"); jsoncons::jsonschema::json_schema schema = loadSchema(str_schema); try { // throws jsoncons::jsonschema::validation_error on failure schema.validate(doc); } catch (const jsoncons::jsonschema::validation_error &e) { - printer::print(printer::CLI_LEVEL_ERROR, e.what()); + LOG("JSON validation failed error=%s", e.what()); + UPDATE_CALF_WORKFLOW_NAME(""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", e.what()); throw ParserException("JSON validation failed!"); } } @@ -46,18 +55,27 @@ void capiocl::parser::Parser::validate_json(const jsoncons::json &doc, const cha capiocl::engine::Engine *capiocl::parser::Parser::parse(const std::filesystem::path &source, const std::filesystem::path &resolve_prefix, bool store_only_in_memory) { - + START_LOG(calf_current_tid(), "call()"); + LOG("parse requested source=%s resolve_prefix=%s memory_only=%d", source.string().c_str(), + resolve_prefix.string().c_str(), static_cast(store_only_in_memory)); if (source.empty()) { throw ParserException("Empty source file name!"); } std::ifstream file(source); if (!file.is_open()) { + LOG("failed to open parse source=%s", source.string().c_str()); throw ParserException("Failed to open file!"); } std::string capio_cl_release; { - jsoncons::json doc = jsoncons::json::parse(file); + jsoncons::json doc; + try { + doc = jsoncons::json::parse(file); + } catch (const jsoncons::json_exception &e) { + LOG("failed to decode JSON source=%s error=%s", source.string().c_str(), e.what()); + throw; + } if (!doc.contains("version")) { capio_cl_release = CAPIO_CL_VERSION::V1; } else { @@ -66,14 +84,18 @@ capiocl::engine::Engine *capiocl::parser::Parser::parse(const std::filesystem::p } file.close(); - printer::print(printer::CLI_LEVEL_INFO, - "Parsing CAPIO-CL config file for version: " + capio_cl_release); + + UPDATE_CALF_WORKFLOW_NAME(""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing CAPIO-CL config file for version: %s", + capio_cl_release.c_str()); if (capio_cl_release == CAPIO_CL_VERSION::V1) { return available_parsers::parse_v1(source, resolve_prefix, store_only_in_memory); } else if (capio_cl_release == CAPIO_CL_VERSION::V1_1) { return available_parsers::parse_v1_1(source, resolve_prefix, store_only_in_memory); } else { + LOG("unsupported specification version=%s source=%s", capio_cl_release.c_str(), + source.string().c_str()); throw ParserException("Invalid CAPIO-CL specification version!"); } -} \ No newline at end of file +} diff --git a/src/Serializer.cpp b/src/Serializer.cpp index 3af869e..27698bb 100644 --- a/src/Serializer.cpp +++ b/src/Serializer.cpp @@ -2,21 +2,26 @@ #include #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/engine.h" -#include "capiocl/printer.h" #include "capiocl/serializer.h" void capiocl::serializer::Serializer::dump(const engine::Engine &engine, const std::filesystem::path &filename, const std::string &version) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(engine.getWorkflowName()); if (version == CAPIO_CL_VERSION::V1) { - printer::print(printer::CLI_LEVEL_INFO, "Serializing engine with V1 specification"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Serializing engine with V1 specification"); available_serializers::serialize_v1(engine, filename); } else if (version == CAPIO_CL_VERSION::V1_1) { - printer::print(printer::CLI_LEVEL_INFO, "Serializing engine with V1.1 specification"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Serializing engine with V1.1 specification"); available_serializers::serialize_v1_1(engine, filename); } else { + LOG("serializer unavailable version=%s workflow=%s output=%s", version.c_str(), + engine.getWorkflowName().c_str(), filename.string().c_str()); const auto message = "No serializer available for CAPIO-CL version: " + version; throw SerializerException(message); } @@ -24,5 +29,7 @@ void capiocl::serializer::Serializer::dump(const engine::Engine &engine, capiocl::serializer::SerializerException::SerializerException(const std::string &msg) : message(msg) { - printer::print(printer::CLI_LEVEL_ERROR, msg); -} \ No newline at end of file + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", msg.c_str()); +} diff --git a/src/api.cpp b/src/api.cpp index 6adebf9..a1cf4ed 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -9,9 +9,10 @@ #include #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl/api.h" #include "capiocl/engine.h" -#include "capiocl/printer.h" std::mutex _setupMtx; std::condition_variable _setupCv; @@ -20,27 +21,38 @@ bool thread_ready = false; /// @brief Main WebServer thread function void server(const std::string &address, const int port, capiocl::engine::Engine *engine, std::atomic *terminate) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(engine->getWorkflowName()); constexpr int RECV_BUF_SIZE = 65535; const auto &wf_name = engine->getWorkflowName(); int fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) { + LOG("API socket creation failed address=%s port=%d errno=%d", address.c_str(), port, errno); + } int reuse = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) { + LOG("API socket setup failed operation=SO_REUSEADDR errno=%d", errno); + } sockaddr_in localAddr{}; localAddr.sin_family = AF_INET; localAddr.sin_port = htons(port); localAddr.sin_addr.s_addr = INADDR_ANY; - bind(fd, reinterpret_cast(&localAddr), sizeof(localAddr)); + if (bind(fd, reinterpret_cast(&localAddr), sizeof(localAddr)) < 0) { + LOG("API socket setup failed operation=bind errno=%d", errno); + } ip_mreq group{}; group.imr_multiaddr.s_addr = inet_addr(address.c_str()); group.imr_interface.s_addr = INADDR_ANY; - setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &group, sizeof(group)); + if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &group, sizeof(group)) < 0) { + LOG("API socket setup failed operation=IP_ADD_MEMBERSHIP errno=%d", errno); + } char buffer[RECV_BUF_SIZE] = {0}; sockaddr_in srcAddr{}; @@ -50,7 +62,9 @@ void server(const std::string &address, const int port, capiocl::engine::Engine timeval tv{}; tv.tv_sec = 0; tv.tv_usec = 500; - setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) { + LOG("API socket setup failed operation=SO_RCVTIMEO errno=%d", errno); + } thread_ready = true; _setupCv.notify_all(); @@ -88,22 +102,27 @@ void server(const std::string &address, const int port, capiocl::engine::Engine if (workflow_name == wf_name) { engine->add(path, rule); + LOG("applied API rule workflow=%s path=%s", workflow_name.c_str(), path.c_str()); } else { continue; } } catch (const jsoncons::json_exception &e) { - capiocl::printer::print(capiocl::printer::CLI_LEVEL_ERROR, - "APIServer: Received invalid json: " + std::string(e.what())); + LOG("rejected invalid API JSON error=%s", e.what()); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "APIServer: Received invalid json: %s", + e.what()); } } close(fd); + LOG("API server stopped address=%s port=%d", address.c_str(), port); } capiocl::api::CapioClApiServer::CapioClApiServer(engine::Engine *engine, configuration::CapioClConfiguration &config) : capiocl_configuration(config) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(engine->getWorkflowName()); std::string address; int port; @@ -111,12 +130,14 @@ capiocl::api::CapioClApiServer::CapioClApiServer(engine::Engine *engine, config.getParameter("dynamic_api.ip", &address); // GCOVR_EXCL_LINE } catch (...) { address = configuration::defaults::DEFAULT_API_MULTICAST_IP.v; + LOG("API configuration fallback key=dynamic_api.ip value=%s", address.c_str()); } try { config.getParameter("dynamic_api.port", &port); // GCOVR_EXCL_LINE } catch (...) { port = std::stoi(configuration::defaults::DEFAULT_API_MULTICAST_PORT.v); + LOG("API configuration fallback key=dynamic_api.port value=%d", port); } _webApiThread = std::thread(server, address, port, engine, &_terminate); @@ -124,10 +145,13 @@ capiocl::api::CapioClApiServer::CapioClApiServer(engine::Engine *engine, std::unique_lock lock(_setupMtx); _setupCv.wait(lock, [] { return thread_ready; }); - printer::print(printer::CLI_LEVEL_INFO, "API server @ " + address + ":" + std::to_string(port)); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "API server @ %s:%d", address.c_str(), port); + LOG("API server thread ready address=%s port=%d", address.c_str(), port); } capiocl::api::CapioClApiServer::~CapioClApiServer() { + START_LOG(calf_current_tid(), "call()"); _terminate = true; _webApiThread.join(); + LOG("API server thread joined"); } diff --git a/src/configuration.cpp b/src/configuration.cpp index ad62d09..6362979 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -1,13 +1,15 @@ #include #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl/configuration.h" -#include "capiocl/printer.h" #include "toml++/toml.hpp" void load_config_to_memory(const toml::table &tbl, std::unordered_map &map, const std::string &prefix = "") { + START_LOG(calf_current_tid(), "call()"); for (const auto &[key, value] : tbl) { std::string full_key; if (prefix.empty()) { @@ -35,6 +37,7 @@ void load_config_to_memory(const toml::table &tbl, } void capiocl::configuration::CapioClConfiguration::loadDefaults() { + START_LOG(calf_current_tid(), "call()"); this->set(defaults::DEFAULT_MONITOR_MCAST_IP); this->set(defaults::DEFAULT_MONITOR_MCAST_PORT); this->set(defaults::DEFAULT_MONITOR_HOMENODE_IP); @@ -44,17 +47,22 @@ void capiocl::configuration::CapioClConfiguration::loadDefaults() { this->set(defaults::DEFAULT_MONITOR_MCAST_ENABLED); this->set(defaults::DEFAULT_API_MULTICAST_PORT); this->set(defaults::DEFAULT_API_MULTICAST_IP); + LOG("loaded configuration defaults parameters=%zu", config.size()); } void capiocl::configuration::CapioClConfiguration::set(const std::string &key, std::string value) { + START_LOG(calf_current_tid(), "call()"); config[key] = std::move(value); } void capiocl::configuration::CapioClConfiguration::set(const ConfigurationEntry &entry) { + START_LOG(calf_current_tid(), "call()"); this->set(entry.k, entry.v); } void capiocl::configuration::CapioClConfiguration::load(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); + LOG("loading configuration path=%s", path.string().c_str()); if (path.empty()) { throw CapioClConfigurationException("Empty pathname!"); } @@ -63,16 +71,18 @@ void capiocl::configuration::CapioClConfiguration::load(const std::filesystem::p try { tbl = toml::parse_file(path.string()); } catch (const toml::parse_error &err) { + LOG("failed to parse configuration path=%s error=%s", path.string().c_str(), err.what()); throw CapioClConfigurationException(err.what()); } // copy into the local configuration the parameter from the toml config file load_config_to_memory(tbl, config); + LOG("loaded configuration path=%s parameters=%zu", path.string().c_str(), config.size()); } void capiocl::configuration::CapioClConfiguration::getParameter(const std::string &key, int *value) const { - + START_LOG(calf_current_tid(), "call()"); if (config.find(key) != config.end()) { *value = std::stoi(config.at(key)); } else { @@ -82,6 +92,7 @@ void capiocl::configuration::CapioClConfiguration::getParameter(const std::strin void capiocl::configuration::CapioClConfiguration::getParameter(const std::string &key, std::string *value) const { + START_LOG(calf_current_tid(), "call()"); if (config.find(key) != config.end()) { *value = config.at(key); } else { @@ -91,5 +102,7 @@ void capiocl::configuration::CapioClConfiguration::getParameter(const std::strin capiocl::configuration::CapioClConfigurationException::CapioClConfigurationException( const std::string &msg) : message(msg) { - printer::print(printer::CLI_LEVEL_ERROR, msg); -} \ No newline at end of file + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(""); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", msg.c_str()); +} diff --git a/src/monitors/FileSystem.cpp b/src/monitors/FileSystem.cpp index 7f48f12..c58992f 100644 --- a/src/monitors/FileSystem.cpp +++ b/src/monitors/FileSystem.cpp @@ -1,12 +1,14 @@ #include #include +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/monitor.h" std::filesystem::path capiocl::monitor::FileSystemMonitor::compute_capiocl_token_name(const std::filesystem::path &path, CAPIO_CL_COMMIT_TOKEN_TYPES type) { + START_LOG(calf_current_tid(), "call()"); std::string token_type; if (type == COMMIT) { @@ -22,46 +24,69 @@ capiocl::monitor::FileSystemMonitor::compute_capiocl_token_name(const std::files void capiocl::monitor::FileSystemMonitor::generate_home_node_token( const std::filesystem::path &path, const std::string &home_node) { + START_LOG(calf_current_tid(), "call()"); if (const auto token_name = compute_capiocl_token_name(path, HOME_NODE); !std::filesystem::exists(token_name)) { std::filesystem::create_directories(token_name.parent_path()); std::ofstream file(token_name); file << home_node << std::endl; + if (!file.good()) { + LOG("failed to write home-node token=%s node=%s", token_name.string().c_str(), + home_node.c_str()); + } else { + LOG("created home-node token=%s node=%s", token_name.string().c_str(), + home_node.c_str()); + } file.close(); } } void capiocl::monitor::FileSystemMonitor::generate_commit_token(const std::filesystem::path &path) { + START_LOG(calf_current_tid(), "call()"); if (const auto token_name = compute_capiocl_token_name(path, COMMIT); !std::filesystem::exists(token_name)) { std::filesystem::create_directories(token_name.parent_path()); std::ofstream file(token_name); + if (!file.good()) { + LOG("failed to create commit token=%s", token_name.string().c_str()); + } else { + LOG("created commit token=%s", token_name.string().c_str()); + } file.close(); } } -capiocl::monitor::FileSystemMonitor::FileSystemMonitor() { gethostname(_hostname, HOST_NAME_MAX); } +capiocl::monitor::FileSystemMonitor::FileSystemMonitor() { + START_LOG(calf_current_tid(), "call()"); + gethostname(_hostname, sizeof(_hostname)); + _hostname[sizeof(_hostname) - 1] = '\0'; + LOG("filesystem monitor initialized hostname=%s", _hostname); +} void capiocl::monitor::FileSystemMonitor::setCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); generate_commit_token(path); } bool capiocl::monitor::FileSystemMonitor::isCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); return std::filesystem::exists(compute_capiocl_token_name(path)); } void capiocl::monitor::FileSystemMonitor::setHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); generate_home_node_token(path, _hostname); } -const std::string & +std::string capiocl::monitor::FileSystemMonitor::getHomeNode(const std::filesystem::path &path) const { - + START_LOG(calf_current_tid(), "call()"); auto home_node_token = compute_capiocl_token_name(path, HOME_NODE); std::lock_guard lg(home_node_lock); if (const auto it = _home_nodes.find(path); it != _home_nodes.end()) { + LOG("home-node cache hit path=%s node=%s", path.string().c_str(), it->second.c_str()); return it->second; } @@ -74,5 +99,6 @@ capiocl::monitor::FileSystemMonitor::getHomeNode(const std::filesystem::path &pa } auto [entry, _] = _home_nodes.emplace(path, std::move(home_node)); + LOG("resolved home node path=%s node=%s", path.string().c_str(), entry->second.c_str()); return entry->second; -} \ No newline at end of file +} diff --git a/src/monitors/Interface.cpp b/src/monitors/Interface.cpp index 05e94dc..d30fdeb 100644 --- a/src/monitors/Interface.cpp +++ b/src/monitors/Interface.cpp @@ -1,26 +1,31 @@ +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/monitor.h" bool capiocl::monitor::MonitorInterface::isCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::string msg = "Attempted to use MonitorInterface as Monitor backend to check commit for: "; msg += path.string(); throw MonitorException(msg); } void capiocl::monitor::MonitorInterface::setCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::string msg = "Attempted to use MonitorInterface as Monitor backend to set commit for: "; msg += path.string(); throw MonitorException(msg); } void capiocl::monitor::MonitorInterface::setHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::string msg = "Attempted to use MonitorInterface as Monitor backend to set commit for: "; msg += path.string(); throw MonitorException(msg); } -const std::string & +std::string capiocl::monitor::MonitorInterface::getHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); std::string msg = "Attempted to use MonitorInterface as Monitor backend to set commit for: "; msg += path.string(); throw MonitorException(msg); -} \ No newline at end of file +} diff --git a/src/monitors/Multicast.cpp b/src/monitors/Multicast.cpp index 1f82fc3..e59f0cf 100644 --- a/src/monitors/Multicast.cpp +++ b/src/monitors/Multicast.cpp @@ -2,13 +2,15 @@ #include #include #include +#include +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/monitor.h" -#include "capiocl/printer.h" static std::tuple outgoing_socket_multicast(const std::string &address, const int port) { + START_LOG(calf_current_tid(), "call()"); sockaddr_in addr{}; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr(address.c_str()); @@ -17,8 +19,11 @@ static std::tuple outgoing_socket_multicast(const std::string const int transmission_socket = socket(AF_INET, SOCK_DGRAM, 0); // LCOV_EXCL_START if (transmission_socket < 0) { + const int error = errno; + LOG("multicast socket failed direction=outgoing address=%s port=%d errno=%d", + address.c_str(), port, error); throw capiocl::monitor::MonitorException(std::string("socket() failed: ") + - strerror(errno)); + strerror(error)); } // LCOV_EXCL_STOP @@ -27,6 +32,7 @@ static std::tuple outgoing_socket_multicast(const std::string static int incoming_socket_multicast(const std::string &address_ip, const int port, sockaddr_in &addr, socklen_t &addrlen) { + START_LOG(calf_current_tid(), "call()"); constexpr int loopback = 1; // enable reception of loopback messages constexpr int multi_bind = 1; // enable multiple sockets on same address @@ -44,31 +50,49 @@ static int incoming_socket_multicast(const std::string &address_ip, const int po // LCOV_EXCL_START if (_socket < 0) { + LOG("multicast socket failed direction=incoming address=%s port=%d errno=%d", + address_ip.c_str(), port, errno); throw capiocl::monitor::MonitorException(std::string("socket() failed: ") + strerror(errno)); } // Allow multiple sockets to bind to the same port if (setsockopt(_socket, SOL_SOCKET, SO_REUSEPORT, &multi_bind, sizeof(multi_bind)) < 0) { + const int error = errno; + LOG("multicast setup failed operation=SO_REUSEPORT address=%s port=%d errno=%d", + address_ip.c_str(), port, error); + close(_socket); throw capiocl::monitor::MonitorException(std::string("REUSEPORT failed: ") + - strerror(errno)); + strerror(error)); } // Bind to port if (bind(_socket, reinterpret_cast(&addr), addrlen) < 0) { - throw capiocl::monitor::MonitorException(std::string("bind failed: ") + strerror(errno)); + const int error = errno; + LOG("multicast setup failed operation=bind address=%s port=%d errno=%d", address_ip.c_str(), + port, error); + close(_socket); + throw capiocl::monitor::MonitorException(std::string("bind failed: ") + strerror(error)); } // Join multicast group if (setsockopt(_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { + const int error = errno; + LOG("multicast setup failed operation=IP_ADD_MEMBERSHIP address=%s port=%d errno=%d", + address_ip.c_str(), port, error); + close(_socket); throw capiocl::monitor::MonitorException(std::string("join multicast failed: ") + - strerror(errno)); + strerror(error)); } // Enable loopback if (setsockopt(_socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, sizeof(loopback)) < 0) { + const int error = errno; + LOG("multicast setup failed operation=IP_MULTICAST_LOOP address=%s port=%d errno=%d", + address_ip.c_str(), port, error); + close(_socket); throw capiocl::monitor::MonitorException(std::string("loopback failed: ") + - strerror(errno)); + strerror(error)); } // LCOV_EXCL_STOP @@ -80,11 +104,16 @@ void capiocl::monitor::MulticastMonitor::commit_listener(std::vector *terminate) { - pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr); + START_LOG(calf_current_tid(), "call()"); sockaddr_in addr_in = {}; socklen_t addr_len = {}; - const auto socket = incoming_socket_multicast(ip_addr, ip_port, addr_in, addr_len); - const auto addr = reinterpret_cast(&addr_in); + int socket; + try { + socket = incoming_socket_multicast(ip_addr, ip_port, addr_in, addr_len); + } catch (const MonitorException &) { + return; + } + const auto addr = reinterpret_cast(&addr_in); char incoming_message[MESSAGE_SIZE] = {0}; // Polling for non blocking @@ -108,12 +137,18 @@ void capiocl::monitor::MulticastMonitor::commit_listener(std::vector(incoming_size)); + if (msg.size() < 2) { + continue; + } + const auto path = msg.substr(2); if (const char command = incoming_message[0]; command == SET) { // Received an advert for a committed file @@ -121,6 +156,7 @@ void capiocl::monitor::MulticastMonitor::commit_listener(std::vector &home_nodes, std::mutex &lock, const std::string &ip_addr, int ip_port, const std::atomic *terminate) { - pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr); - - char this_hostname[HOST_NAME_MAX] = {}; - gethostname(this_hostname, HOST_NAME_MAX); + START_LOG(calf_current_tid(), "call()"); + char this_hostname[HOSTNAME_BUFFER_SIZE] = {}; + gethostname(this_hostname, sizeof(this_hostname)); + this_hostname[sizeof(this_hostname) - 1] = '\0'; sockaddr_in addr_in = {}; socklen_t addr_len = {}; - const auto socket = incoming_socket_multicast(ip_addr, ip_port, addr_in, addr_len); + int socket; + try { + socket = incoming_socket_multicast(ip_addr, ip_port, addr_in, addr_len); + } catch (const MonitorException &) { + return; + } const auto addr = reinterpret_cast(&addr_in); char incoming_message[MESSAGE_SIZE] = {0}; @@ -169,12 +210,14 @@ void capiocl::monitor::MulticastMonitor::home_node_listener( } // LCOV_EXCL_START - if (recvfrom(socket, incoming_message, MESSAGE_SIZE, MSG_DONTWAIT, addr, &addr_len) < 0) { + const auto incoming_size = + recvfrom(socket, incoming_message, MESSAGE_SIZE, MSG_DONTWAIT, addr, &addr_len); + if (incoming_size < 0) { continue; } // LCOV_EXCL_STOP - std::string incoming_message_str(incoming_message); + std::string incoming_message_str(incoming_message, incoming_size); std::vector tokens; size_t start = 0, end = incoming_message_str.find(' '); @@ -189,22 +232,33 @@ void capiocl::monitor::MulticastMonitor::home_node_listener( if (start < incoming_message_str.length()) { tokens.push_back(incoming_message_str.substr(start)); } - const auto &path = tokens[1]; - if (tokens[0].c_str()[0] == SET) { - // Received an advert for a committed file - std::lock_guard lg(lock); + // Drop anything that isn't a well-formed message. + if (tokens.empty()) { + continue; + } + if (const char command = tokens[0].c_str()[0]; command == SET) { + if (tokens.size() < 3) { + // need "! " -> malformed message, skip + continue; + } + const auto &path = tokens[1]; const auto &home_node = tokens[2]; - home_nodes[path] = home_node; + std::lock_guard lg(lock); + home_nodes[path] = home_node; + LOG("received home node path=%s node=%s", path.c_str(), home_node.c_str()); } else { // Received a query for a home node, Message begins with capiocl::Monitor::REQUEST + if (tokens.size() < 2) { + // need "? " -> malformed message, skip + continue; + } + const auto &path = tokens[1]; std::lock_guard lg(lock); - if (home_nodes.find(path) == home_nodes.end()) { continue; } - if (home_nodes[path] == this_hostname) { _send_message(ip_addr, ip_port, path + " " + this_hostname, SET); } @@ -215,20 +269,32 @@ void capiocl::monitor::MulticastMonitor::home_node_listener( void capiocl::monitor::MulticastMonitor::_send_message(const std::string &ip_addr, const int ip_port, const std::string &path, const MESSAGE_COMMANDS action) { + START_LOG(calf_current_tid(), "call()"); char message[MESSAGE_SIZE] = {0}; snprintf(message, sizeof(message), "%c %s", action, path.c_str()); auto [out_s, addr] = outgoing_socket_multicast(ip_addr, ip_port); - sendto(out_s, message, strlen(message), 0, reinterpret_cast(&addr), sizeof(addr)); + if (sendto(out_s, message, strlen(message), 0, reinterpret_cast(&addr), + sizeof(addr)) < 0) { + LOG("multicast send failed address=%s port=%d action=%c path=%s errno=%d", ip_addr.c_str(), + ip_port, action, path.c_str(), errno); + } else { + LOG("multicast message sent address=%s port=%d action=%c path=%s", ip_addr.c_str(), ip_port, + action, path.c_str()); + } close(out_s); } capiocl::monitor::MulticastMonitor::MulticastMonitor( const configuration::CapioClConfiguration &config) { + START_LOG(calf_current_tid(), "call()"); config.getParameter("monitor.mcast.commit.ip", &MULTICAST_COMMIT_ADDR); config.getParameter("monitor.mcast.commit.port", &MULTICAST_COMMIT_PORT); config.getParameter("monitor.mcast.homenode.ip", &MULTICAST_HOME_NODE_ADDR); config.getParameter("monitor.mcast.homenode.port", &MULTICAST_HOME_NODE_PORT); config.getParameter("monitor.mcast.delay_ms", &MULTICAST_DELAY_MILLIS); + LOG("multicast monitor configured commit=%s:%d home_node=%s:%d delay_ms=%d", + MULTICAST_COMMIT_ADDR.c_str(), MULTICAST_COMMIT_PORT, MULTICAST_HOME_NODE_ADDR.c_str(), + MULTICAST_HOME_NODE_PORT, MULTICAST_DELAY_MILLIS); commit_thread = std::thread(&commit_listener, std::ref(_committed_files), std::ref(committed_lock), @@ -238,23 +304,19 @@ capiocl::monitor::MulticastMonitor::MulticastMonitor( std::thread(&home_node_listener, std::ref(_home_nodes), std::ref(home_node_lock), MULTICAST_HOME_NODE_ADDR, MULTICAST_HOME_NODE_PORT, &this->terminate); - gethostname(_hostname, HOST_NAME_MAX); + gethostname(_hostname, sizeof(_hostname)); + _hostname[sizeof(_hostname) - 1] = '\0'; } capiocl::monitor::MulticastMonitor::~MulticastMonitor() { - + START_LOG(calf_current_tid(), "call()"); terminate = true; - - if (commit_thread.joinable()) { - commit_thread.join(); - } - if (home_node_thread.joinable()) { - home_node_thread.join(); - } + commit_thread.join(); + home_node_thread.join(); } bool capiocl::monitor::MulticastMonitor::isCommitted(const std::filesystem::path &path) const { - + START_LOG(calf_current_tid(), "call()"); { const std::lock_guard lg(committed_lock); if (std::find(_committed_files.begin(), _committed_files.end(), path) != @@ -265,7 +327,6 @@ bool capiocl::monitor::MulticastMonitor::isCommitted(const std::filesystem::path _send_message(MULTICAST_COMMIT_ADDR, MULTICAST_COMMIT_PORT, path, GET); std::this_thread::sleep_for(std::chrono::milliseconds(MULTICAST_DELAY_MILLIS)); - { const std::lock_guard lg(committed_lock); return std::find(_committed_files.begin(), _committed_files.end(), path) != @@ -274,6 +335,7 @@ bool capiocl::monitor::MulticastMonitor::isCommitted(const std::filesystem::path } void capiocl::monitor::MulticastMonitor::setCommitted(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); _send_message(MULTICAST_COMMIT_ADDR, MULTICAST_COMMIT_PORT, std::filesystem::path(path), SET); std::lock_guard lg(committed_lock); const auto position = std::find(_committed_files.begin(), _committed_files.end(), path); @@ -283,6 +345,7 @@ void capiocl::monitor::MulticastMonitor::setCommitted(const std::filesystem::pat } void capiocl::monitor::MulticastMonitor::setHomeNode(const std::filesystem::path &path) const { + START_LOG(calf_current_tid(), "call()"); const std::string message = path.string() + " " + _hostname; _send_message(MULTICAST_HOME_NODE_ADDR, MULTICAST_HOME_NODE_PORT, message, SET); @@ -290,9 +353,9 @@ void capiocl::monitor::MulticastMonitor::setHomeNode(const std::filesystem::path _home_nodes[path] = _hostname; } -const std::string & +std::string capiocl::monitor::MulticastMonitor::getHomeNode(const std::filesystem::path &path) const { - + START_LOG(calf_current_tid(), "call()"); { const std::lock_guard lg(home_node_lock); if (const auto itm = _home_nodes.find(path); itm != _home_nodes.end()) { @@ -309,4 +372,4 @@ capiocl::monitor::MulticastMonitor::getHomeNode(const std::filesystem::path &pat } else { return NO_HOME_NODE; } -} \ No newline at end of file +} diff --git a/src/parsers/v1.1.cpp b/src/parsers/v1.1.cpp index 070dc58..b03093f 100644 --- a/src/parsers/v1.1.cpp +++ b/src/parsers/v1.1.cpp @@ -1,15 +1,17 @@ #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capio_cl_json_schemas.hpp" #include "capiocl.hpp" #include "capiocl/engine.h" #include "capiocl/parser.h" -#include "capiocl/printer.h" capiocl::engine::Engine * capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::path &source, const std::filesystem::path &resolve_prefix, bool store_only_in_memory) { + START_LOG(calf_current_tid(), "call()"); std::string workflow_name = CAPIO_CL_DEFAULT_WF_NAME; auto engine = new engine::Engine(false); @@ -22,12 +24,15 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa // ---- workflow name ---- workflow_name = doc["name"].as(); engine->setWorkflowName(workflow_name); - printer::print(printer::CLI_LEVEL_JSON, "Parsing configuration for workflow: " + workflow_name); + UPDATE_CALF_WORKFLOW_NAME(workflow_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing configuration for workflow: %s", + workflow_name.c_str()); // ---- CAPIO-CL TOML CONFIGURATION ---- if (doc.contains("configuration")) { auto toml_config_path = doc["configuration"].as(); - printer::print(printer::CLI_LEVEL_JSON, "Using configuration file : " + toml_config_path); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Using TOML configuration file: %s", + toml_config_path.c_str()); engine->loadConfiguration(toml_config_path); } else { engine->useDefaultConfiguration(); @@ -36,10 +41,10 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa // ---- IO_Graph ---- for (const auto &app : doc["IO_Graph"].array_range()) { std::string app_name = app["name"].as(); - printer::print(printer::CLI_LEVEL_JSON, "Parsing config for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing config for app: %s", app_name.c_str()); // ---- input_stream ---- - printer::print(printer::CLI_LEVEL_JSON, "Parsing input_stream for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing input_stream for app: %s", app_name.c_str()); for (const auto &itm : app["input_stream"].array_range()) { auto file_path = resolve(itm.as(), resolve_prefix); engine->newFile(file_path); @@ -47,7 +52,8 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa } // ---- output_stream ---- - printer::print(printer::CLI_LEVEL_JSON, "Parsing output_stream for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing output_stream for app: %s", + app_name.c_str()); for (const auto &itm : app["output_stream"].array_range()) { auto file_path = resolve(itm.as(), resolve_prefix); engine->newFile(file_path); @@ -56,7 +62,8 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa // ---- streaming ---- if (app.contains("streaming")) { - printer::print(printer::CLI_LEVEL_JSON, "Parsing streaming for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing streaming section for app: %s", + app_name.c_str()); for (const auto &stream_item : app["streaming"].array_range()) { bool is_file = true; std::vector streaming_names; @@ -169,7 +176,7 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa engine->setStoreFileInMemory(file_str); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No MEM storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No MEM storage section found"); } if (storage.contains("fs")) { @@ -178,17 +185,19 @@ capiocl::parser::Parser::available_parsers::parse_v1_1(const std::filesystem::pa engine->setStoreFileInFileSystem(file_str); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No FS storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No FS storage section found"); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No STORAGE storage section found"); } // ---- Store only in memory ---- if (store_only_in_memory) { - printer::print(printer::CLI_LEVEL_INFO, "Storing all files in memory"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Storing all files in memory"); engine->setAllStoreInMemory(); } + LOG("parsed v1.1 source=%s workflow=%s entries=%zu memory_only=%d", source.string().c_str(), + workflow_name.c_str(), engine->size(), static_cast(store_only_in_memory)); return engine; -} \ No newline at end of file +} diff --git a/src/parsers/v1.cpp b/src/parsers/v1.cpp index af2e645..bc845a1 100644 --- a/src/parsers/v1.cpp +++ b/src/parsers/v1.cpp @@ -1,15 +1,17 @@ #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capio_cl_json_schemas.hpp" #include "capiocl.hpp" #include "capiocl/engine.h" #include "capiocl/parser.h" -#include "capiocl/printer.h" capiocl::engine::Engine * capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path &source, const std::filesystem::path &resolve_prefix, bool store_only_in_memory) { + START_LOG(calf_current_tid(), "call()"); std::string workflow_name = CAPIO_CL_DEFAULT_WF_NAME; auto engine = new engine::Engine(true); @@ -24,15 +26,17 @@ capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path // ---- workflow name ---- workflow_name = doc["name"].as(); engine->setWorkflowName(workflow_name); - printer::print(printer::CLI_LEVEL_JSON, "Parsing configuration for workflow: " + workflow_name); + UPDATE_CALF_WORKFLOW_NAME(workflow_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing configuration for workflow: %s", + workflow_name.c_str()); // ---- IO_Graph ---- for (const auto &app : doc["IO_Graph"].array_range()) { std::string app_name = app["name"].as(); - printer::print(printer::CLI_LEVEL_JSON, "Parsing config for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing config for app: %s", app_name.c_str()); // ---- input_stream ---- - printer::print(printer::CLI_LEVEL_JSON, "Parsing input_stream for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing input_stream for app: %s", app_name.c_str()); for (const auto &itm : app["input_stream"].array_range()) { auto file_path = resolve(itm.as(), resolve_prefix); engine->newFile(file_path); @@ -40,7 +44,8 @@ capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path } // ---- output_stream ---- - printer::print(printer::CLI_LEVEL_JSON, "Parsing output_stream for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing output_stream for app: %s", + app_name.c_str()); for (const auto &itm : app["output_stream"].array_range()) { auto file_path = resolve(itm.as(), resolve_prefix); engine->newFile(file_path); @@ -49,7 +54,8 @@ capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path // ---- streaming ---- if (app.contains("streaming")) { - printer::print(printer::CLI_LEVEL_JSON, "Parsing streaming for app " + app_name); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing streaming section for app: %s", + app_name.c_str()); for (const auto &stream_item : app["streaming"].array_range()) { bool is_file = true; std::vector streaming_names; @@ -162,7 +168,7 @@ capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path engine->setStoreFileInMemory(file_str); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No MEM storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No MEM storage section found"); } if (storage.contains("fs")) { @@ -171,17 +177,19 @@ capiocl::parser::Parser::available_parsers::parse_v1(const std::filesystem::path engine->setStoreFileInFileSystem(file_str); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No FS storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No FS storage section found"); } } else { - printer::print(printer::CLI_LEVEL_INFO, "No storage section found"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "No STORAGE storage section found"); } // ---- Store only in memory ---- if (store_only_in_memory) { - printer::print(printer::CLI_LEVEL_INFO, "Storing all files in memory"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Storing all files in memory"); engine->setAllStoreInMemory(); } + LOG("parsed v1 source=%s workflow=%s entries=%zu memory_only=%d", source.string().c_str(), + workflow_name.c_str(), engine->size(), static_cast(store_only_in_memory)); return engine; -} \ No newline at end of file +} diff --git a/src/serializers/v1.1.cpp b/src/serializers/v1.1.cpp index b862711..677780c 100644 --- a/src/serializers/v1.1.cpp +++ b/src/serializers/v1.1.cpp @@ -1,12 +1,15 @@ #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/engine.h" -#include "capiocl/printer.h" #include "capiocl/serializer.h" void capiocl::serializer::Serializer::available_serializers::serialize_v1_1( const engine::Engine &engine, const std::filesystem::path &filename) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(engine.getWorkflowName()); jsoncons::json doc; doc["version"] = 1.1; doc["name"] = engine.getWorkflowName(); @@ -58,9 +61,9 @@ void capiocl::serializer::Serializer::available_serializers::serialize_v1_1( const auto close_count = std::to_string(entry.commit_on_close_count); streaming_item["committed"] = entry.commit_rule + ":" + close_count; } else { - const auto msg = "Commit rule is not ON_CLOSE but close count > 0"; - printer::print(printer::CLI_LEVEL_WARNING, msg); - printer::print(printer::CLI_LEVEL_WARNING, "Setting commit rule = ON_CLOSE"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, + "Commit rule is not ON_CLOSE but close count > 0"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Setting commit rule = ON_CLOSE"); streaming_item["committed"] = std::string(commitRules::ON_CLOSE) + ":" + std::to_string(entry.commit_on_close_count); } @@ -120,9 +123,18 @@ void capiocl::serializer::Serializer::available_serializers::serialize_v1_1( std::ofstream out(filename); if (!out.is_open()) { + LOG("failed to open serialization output=%s", filename.string().c_str()); throw SerializerException("Failed to open output file: " + filename.string()); } out << jsoncons::pretty_print(doc) << std::endl; - - printer::print(printer::CLI_LEVEL_INFO, "Configuration serialized to " + filename.string()); -} \ No newline at end of file + if (!out.good()) { + LOG("failed to write serialization output=%s stream_state=%d", filename.string().c_str(), + static_cast(out.rdstate())); + } else { + LOG("serialized v1.1 workflow=%s output=%s entries=%zu applications=%zu", + engine.getWorkflowName().c_str(), filename.string().c_str(), files.size(), + io_graph.size()); + } + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Configuration serialized to %s", + filename.string().c_str()); +} diff --git a/src/serializers/v1.cpp b/src/serializers/v1.cpp index f43a09d..5151843 100644 --- a/src/serializers/v1.cpp +++ b/src/serializers/v1.cpp @@ -1,12 +1,15 @@ #include +#include "calf/StdOutLogger.h" +#include "calf/StlLogger.h" #include "capiocl.hpp" #include "capiocl/engine.h" -#include "capiocl/printer.h" #include "capiocl/serializer.h" void capiocl::serializer::Serializer::available_serializers::serialize_v1( const engine::Engine &engine, const std::filesystem::path &filename) { + START_LOG(calf_current_tid(), "call()"); + UPDATE_CALF_WORKFLOW_NAME(engine.getWorkflowName()); jsoncons::json doc; doc["name"] = engine.getWorkflowName(); @@ -57,9 +60,9 @@ void capiocl::serializer::Serializer::available_serializers::serialize_v1( const auto close_count = std::to_string(entry.commit_on_close_count); streaming_item["committed"] = entry.commit_rule + ":" + close_count; } else { - const auto msg = "Commit rule is not ON_CLOSE but close count > 0"; - printer::print(printer::CLI_LEVEL_WARNING, msg); - printer::print(printer::CLI_LEVEL_WARNING, "Setting commit rule = ON_CLOSE"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, + "Commit rule is not ON_CLOSE but close count > 0"); + CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Setting commit rule = ON_CLOSE"); streaming_item["committed"] = std::string(commitRules::ON_CLOSE) + ":" + std::to_string(entry.commit_on_close_count); } @@ -119,9 +122,18 @@ void capiocl::serializer::Serializer::available_serializers::serialize_v1( std::ofstream out(filename); if (!out.is_open()) { + LOG("failed to open serialization output=%s", filename.string().c_str()); throw SerializerException("Failed to open output file: " + filename.string()); } out << jsoncons::pretty_print(doc) << std::endl; - - printer::print(printer::CLI_LEVEL_INFO, "Configuration serialized to " + filename.string()); -} \ No newline at end of file + if (!out.good()) { + LOG("failed to write serialization output=%s stream_state=%d", filename.string().c_str(), + static_cast(out.rdstate())); + } else { + LOG("serialized v1 workflow=%s output=%s entries=%zu applications=%zu", + engine.getWorkflowName().c_str(), filename.string().c_str(), files.size(), + io_graph.size()); + } + CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Configuration serialized to %s", + filename.string().c_str()); +} diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp index 29f742f..1163cb9 100644 --- a/tests/cpp/main.cpp +++ b/tests/cpp/main.cpp @@ -18,7 +18,6 @@ template std::string demangled_name(const T &obj) { #include "capiocl/engine.h" #include "capiocl/monitor.h" #include "capiocl/parser.h" -#include "capiocl/printer.h" #include "capiocl/serializer.h" #include "test_apis.hpp" diff --git a/tests/cpp/test_exceptions.hpp b/tests/cpp/test_exceptions.hpp index 9356939..c4bcd63 100644 --- a/tests/cpp/test_exceptions.hpp +++ b/tests/cpp/test_exceptions.hpp @@ -43,8 +43,8 @@ TEST(EXCEPTION_SUITE_NAME, testFailedserializeVersion) { TEST(EXCEPTION_SUITE_NAME, testParserException) { std::filesystem::path JSON_DIR = "/tmp/capio_cl_jsons/"; - capiocl::printer::print(capiocl::printer::CLI_LEVEL_INFO, - "Loading jsons from " + JSON_DIR.string()); + + std::cout << "Loading jsons from " << JSON_DIR << std::endl; std::vector test_filenames = { "", @@ -77,8 +77,7 @@ TEST(EXCEPTION_SUITE_NAME, testParserException) { for (const auto &version : CAPIO_CL_AVAIL_VERSIONS) { for (const auto &test : test_filenames) { const auto test_file_path = test.empty() ? test : JSON_DIR / ("V" + version) / test; - capiocl::printer::print(capiocl::printer::CLI_LEVEL_WARNING, - "Testing on file " + test_file_path.string()); + std::cout << "Testing on file " << test_file_path << std::endl; EXPECT_THROW(capiocl::parser::Parser::parse(test_file_path), capiocl::parser::ParserException); diff --git a/tests/cpp/test_monitor.hpp b/tests/cpp/test_monitor.hpp index 7189282..ba0f127 100644 --- a/tests/cpp/test_monitor.hpp +++ b/tests/cpp/test_monitor.hpp @@ -70,8 +70,8 @@ TEST(MONITOR_SUITE_NAME, testHomeNodeAcrossDifferentThreads) { const auto e1 = new capiocl::engine::Engine(); const auto e2 = new capiocl::engine::Engine(); - char hostname[HOST_NAME_MAX] = {}; - gethostname(hostname, HOST_NAME_MAX); + char hostname[capiocl::monitor::HOSTNAME_BUFFER_SIZE] = {}; + gethostname(hostname, sizeof(hostname)); e1->setHomeNode("test.txt"); const std::set home_nodes = e2->getHomeNode("test.txt"); @@ -87,8 +87,8 @@ TEST(MONITOR_SUITE_NAME, testHomeNodeAcrossDifferentThreads) { } TEST(MONITOR_SUITE_NAME, testHomeNodeAfterSetup) { - char hostname[HOST_NAME_MAX] = {}; - gethostname(hostname, HOST_NAME_MAX); + char hostname[capiocl::monitor::HOSTNAME_BUFFER_SIZE] = {}; + gethostname(hostname, sizeof(hostname)); const capiocl::engine::Engine e; e.setHomeNode("test.txt"); @@ -103,8 +103,8 @@ TEST(MONITOR_SUITE_NAME, testHomeNodeAfterSetup) { } TEST(MONITOR_SUITE_NAME, testHomeNodeAfterInstanceTearDown) { - char hostname[HOST_NAME_MAX] = {}; - gethostname(hostname, HOST_NAME_MAX); + char hostname[capiocl::monitor::HOSTNAME_BUFFER_SIZE] = {}; + gethostname(hostname, sizeof(hostname)); auto e1 = new capiocl::engine::Engine(); @@ -120,4 +120,4 @@ TEST(MONITOR_SUITE_NAME, testHomeNodeAfterInstanceTearDown) { EXPECT_NE(home_nodes.find(hostname), home_nodes.end()); } -#endif // CAPIO_CL_MONITOR_HPP \ No newline at end of file +#endif // CAPIO_CL_MONITOR_HPP diff --git a/tests/cpp/test_serialize_deserialize.hpp b/tests/cpp/test_serialize_deserialize.hpp index 8c0cd1a..96eadb2 100644 --- a/tests/cpp/test_serialize_deserialize.hpp +++ b/tests/cpp/test_serialize_deserialize.hpp @@ -48,7 +48,6 @@ TEST(SERIALIZE_DESERIALIZE_SUITE_NAME, testSerializeParseCAPIOCLV1) { auto new_engine = capiocl::parser::Parser::parse(path, resolve); EXPECT_TRUE(new_engine->getWorkflowName() == workflow_name); - capiocl::printer::print("", ""); EXPECT_TRUE(engine == *new_engine); auto new_engine1 = capiocl::parser::Parser::parse(path, resolve, true); @@ -80,7 +79,6 @@ TEST(SERIALIZE_DESERIALIZE_SUITE_NAME, testSerializeParseCAPIOCLV1NcloseNfiles) auto new_engine = capiocl::parser::Parser::parse(path, resolve); EXPECT_TRUE(new_engine->getWorkflowName() == workflow_name); - capiocl::printer::print("", ""); EXPECT_TRUE(engine == *new_engine); std::filesystem::remove(path); @@ -116,7 +114,6 @@ TEST(SERIALIZE_DESERIALIZE_SUITE_NAME, testSerializeParseCAPIOCLV1FileDeps) { auto new_engine = capiocl::parser::Parser::parse(path, resolve); EXPECT_TRUE(new_engine->getWorkflowName() == workflow_name); - capiocl::printer::print("", ""); EXPECT_TRUE(engine == *new_engine); std::filesystem::remove(path); @@ -146,7 +143,6 @@ TEST(SERIALIZE_DESERIALIZE_SUITE_NAME, testSerializeCommitOnCloseCountNoCommitRu EXPECT_TRUE(new_engine->getWorkflowName() == workflow_name); EXPECT_FALSE(engine == *new_engine); - capiocl::printer::print("", ""); engine.setCommitRule(file_1_name, capiocl::commitRules::ON_CLOSE); EXPECT_TRUE(engine == *new_engine);