diff --git a/score/launch_manager/src/alive/src/details/AliveImpl.cpp b/score/launch_manager/src/alive/src/details/AliveImpl.cpp index 2cdc18768..957c9ea9b 100644 --- a/score/launch_manager/src/alive/src/details/AliveImpl.cpp +++ b/score/launch_manager/src/alive/src/details/AliveImpl.cpp @@ -12,6 +12,7 @@ ********************************************************************************/ #include "score/mw/launch_manager/alive_monitor/details/AliveImpl.h" +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include @@ -23,11 +24,8 @@ namespace score::mw::lifecycle { AliveImpl::AliveImpl(const std::string_view& f_instanceSpecifier_r, - std::unique_ptr f_ipcClient) noexcept(false) - : k_instanceSpecifierPath(f_instanceSpecifier_r), - ipcClient(std::move(f_ipcClient)), - logger_r( - score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::supervision)) + std::unique_ptr f_ipcClient) noexcept(false) + : k_instanceSpecifierPath(f_instanceSpecifier_r), ipcClient(std::move(f_ipcClient)) { // coverity[autosar_cpp14_a15_5_2_violation] This warning comes from pipc-sa(external library) connectToPhmDaemon(); @@ -43,7 +41,7 @@ void AliveImpl::connectToPhmDaemon(void) noexcept(false) const auto ipc_path_res = readInterfacePath(); if (ipc_path_res == std::nullopt) { - logger_r.LogError() << "Failed to load interface path for Alive instance (" << k_instanceSpecifierPath << ")"; + LM_LOG_ERROR() << "Failed to load interface path for Alive instance (" << k_instanceSpecifierPath << ")"; throw std::runtime_error("Failed to get interface path"); } CheckpointIpcClient::EIpcInitResult initResult{ipcClient->init(ipc_path_res.value())}; @@ -54,11 +52,11 @@ void AliveImpl::connectToPhmDaemon(void) noexcept(false) else if (initResult == CheckpointIpcClient::EIpcInitResult::kPermissionDenied) { const uid_t uid{geteuid()}; - logger_r.LogError() << "Connection to PHM daemon failed (permission denied for effective uid" << uid - << "), for the Alive instance (" << k_instanceSpecifierPath << ")"; + LM_LOG_ERROR() << "Connection to PHM daemon failed (permission denied for effective uid" << uid + << "), for the Alive instance (" << k_instanceSpecifierPath << ")"; return; } - logger_r.LogError() << "Connection to PHM daemon failed, for the Alive instance (" << k_instanceSpecifierPath << ")"; + LM_LOG_ERROR() << "Connection to PHM daemon failed, for the Alive instance (" << k_instanceSpecifierPath << ")"; } std::optional AliveImpl::readInterfacePath() noexcept diff --git a/score/launch_manager/src/alive/src/details/AliveImpl.h b/score/launch_manager/src/alive/src/details/AliveImpl.h index 0ea9187c7..6e37a9f25 100644 --- a/score/launch_manager/src/alive/src/details/AliveImpl.h +++ b/score/launch_manager/src/alive/src/details/AliveImpl.h @@ -20,7 +20,6 @@ #include #include "score/mw/launch_manager/alive_monitor/details/ifappl/DataStructures.hpp" #include "score/mw/launch_manager/alive_monitor/details/ipc/IpcClient.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" namespace score::mw::lifecycle { @@ -86,8 +85,6 @@ class AliveImpl /// @brief IPC Connection to PHM Daemon /// Class needs to be mutable to use in "const" reportCheckpoint method mutable std::unique_ptr ipcClient; - /// Logger object - score::lcm::saf::logging::PhmLogger& logger_r; }; } // namespace score::mw::lifecycle diff --git a/score/launch_manager/src/alive/src/details/BUILD b/score/launch_manager/src/alive/src/details/BUILD index d7f10cdbc..d0f15b16d 100644 --- a/score/launch_manager/src/alive/src/details/BUILD +++ b/score/launch_manager/src/alive/src/details/BUILD @@ -32,8 +32,8 @@ cc_library( "//score/launch_manager/src/daemon/src/alive_monitor/config", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:data_structures", "//score/launch_manager/src/daemon/src/alive_monitor/details/ipc:ipc_if", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", + "//score/launch_manager/src/daemon/src/common:log", "@score_baselibs//score/flatbuffers:flatbufferscpp", ], ) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.cpp index d13c256c4..da0424449 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.cpp @@ -18,7 +18,6 @@ #include #include "score/mw/launch_manager/alive_monitor/details/daemon/AliveMonitorImpl.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/watchdog/WatchdogImpl.hpp" namespace score @@ -37,7 +36,6 @@ AliveMonitorImpl::AliveMonitorImpl(SptrIRecoveryClient recovery_client, const Config& config) : m_recovery_client(recovery_client), m_watchdog(std::move(watchdog)), - m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)}, m_process_state_receiver{std::move(process_state_receiver)}, m_config(config) { @@ -48,7 +46,6 @@ AliveMonitorImpl::AliveMonitorImpl(SptrIRecoveryClient recovery_client, UptrIProcessStateReceiver process_state_receiver) : m_recovery_client(recovery_client), m_watchdog(std::move(watchdog)), - m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)}, m_process_state_receiver{std::move(process_state_receiver)} { } @@ -61,7 +58,7 @@ EInitCode AliveMonitorImpl::init() noexcept { m_osClock.startMeasurement(); - m_daemon = std::make_unique(m_osClock, m_logger, std::move(m_watchdog), + m_daemon = std::make_unique(m_osClock, std::move(m_watchdog), std::move(m_process_state_receiver)); #ifdef USE_NEW_CONFIGURATION initResult = m_daemon->init(m_recovery_client, m_config); @@ -72,12 +69,11 @@ EInitCode AliveMonitorImpl::init() noexcept if (initResult == EInitCode::kNoError) { const long ms{m_osClock.endMeasurement()}; - m_logger.LogDebug() << "AliveMonitor: Initialization took " << ms << " ms"; + LM_LOG_DEBUG() << "AliveMonitor: Initialization took " << ms << " ms"; } else { - m_logger.LogError() << "AliveMonitor: Initialization failed with error code:" - << static_cast(initResult); + LM_LOG_ERROR() << "AliveMonitor: Initialization failed with error code:" << static_cast(initResult); } } catch (const std::exception& e) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.hpp index f1a46055c..9dee98561 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/AliveMonitorImpl.hpp @@ -37,7 +37,6 @@ namespace daemon { using SptrIRecoveryClient = std::shared_ptr; using UptrIWatchdogIf = std::unique_ptr; using UptrIProcessStateReceiver = std::unique_ptr; -using Logger = score::lcm::saf::logging::PhmLogger; using UptrPhmDaemon = std::unique_ptr; using OsClock = score::lcm::saf::timers::OsClockInterface; #ifdef USE_NEW_CONFIGURATION @@ -64,7 +63,6 @@ class AliveMonitorImpl : public IAliveMonitor { private: SptrIRecoveryClient m_recovery_client{nullptr}; UptrIWatchdogIf m_watchdog{nullptr}; - Logger& m_logger; UptrPhmDaemon m_daemon{nullptr}; OsClock m_osClock{}; UptrIProcessStateReceiver m_process_state_receiver; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/BUILD index c2688f53e..5eba0d75f 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/BUILD @@ -39,9 +39,9 @@ cc_library( "//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state_reader", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:alive", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", + "//score/launch_manager/src/daemon/src/common:log", ] + select({ "//config:lm_use_new_configuration": [ "//score/launch_manager/src/daemon/src/configuration:config", @@ -69,12 +69,12 @@ cc_library( "//score/launch_manager/src/daemon/src/alive_monitor/details/factory:machine_config_factory", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state_reader", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:alive", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:cycle_time_validator", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:cycle_timer", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", "//score/launch_manager/src/daemon/src/alive_monitor/details/watchdog:i_watchdog_if", + "//score/launch_manager/src/daemon/src/common:log", "//score/launch_manager/src/lifecycle_client", ] + select({ "//config:lm_use_new_configuration": [ @@ -106,7 +106,6 @@ cc_library( visibility = ["//score/launch_manager/src/daemon:__subpackages__"], deps = [ ":i_health_monitor", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/watchdog:watchdog_impl", "@score_baselibs//score/language/futurecpp", ], diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.cpp index af5c43288..5c213dede 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.cpp @@ -32,12 +32,10 @@ namespace daemon /* RULECHECKER_comment(0, 4, check_incomplete_data_member_construction, "Default constructor is used for\ processStateReader.", true_no_defect) */ PhmDaemon::PhmDaemon(OsClock& f_osClock, - Logger& f_logger_r, std::unique_ptr f_watchdog, std::unique_ptr f_process_state_receiver) : osClock{f_osClock}, cycleTimer{&osClock}, - logger_r{f_logger_r}, swClusterHandlers{}, processStateReader{std::move(f_process_state_receiver)}, watchdog(std::move(f_watchdog)) @@ -93,16 +91,15 @@ bool PhmDaemon::construct(const SupervisionBufferConfig& f_bufferConfig_r) noexc score::Result> listSwClustersPhm{{"MainCluster"}}; if (!listSwClustersPhm.has_value()) { - logger_r.LogError() - << "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:" - << listSwClustersPhm.error().Message(); + LM_LOG_ERROR() << "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:" + << listSwClustersPhm.error().Message(); isSuccess = false; } else { if (listSwClustersPhm.value().size() == 0U) { - logger_r.LogWarn() << "Phm Daemon: is starting without any software cluster configurations!"; + LM_LOG_WARN() << "Phm Daemon: is starting without any software cluster configurations!"; } // Reserve the vector swClusterHandlers obtained from flatcfg before constructing the SwClusters @@ -118,8 +115,8 @@ bool PhmDaemon::construct(const SupervisionBufferConfig& f_bufferConfig_r) noexc #endif if (!isSuccess) { - logger_r.LogError() << "Phm Daemon: failed to create worker objects for swclusterhandler:" - << strSwClusterName; + LM_LOG_ERROR() << "Phm Daemon: failed to create worker objects for swclusterhandler:" + << strSwClusterName; break; } } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp index a7e95eb21..54f7fa993 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/PhmDaemon.hpp @@ -18,13 +18,11 @@ #include #include -#include -#include "score/mw/lifecycle/control_client.h" +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/daemon/PhmDaemonConfig.hpp" #include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/MachineConfigFactory.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessStateReader.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/CycleTimeValidator.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/CycleTimer.hpp" #include "score/mw/launch_manager/alive_monitor/details/watchdog/IWatchdogIf.hpp" @@ -62,7 +60,6 @@ class PhmDaemon { public: using OsClock = score::lcm::saf::timers::OsClockInterface; - using Logger = logging::PhmLogger; using Watchdog = watchdog::IWatchdogIf; using ProcessStateReceiver = score::lcm::IProcessStateReceiver; using RecoveryClient = score::lcm::IRecoveryClient; @@ -78,15 +75,15 @@ class PhmDaemon /* RULECHECKER_comment(0, 4, check_expensive_to_copy_in_parameter, "f_supervisionErrorInfo name is passed by value\ as same as generated function", true_no_defect) */ - /// @brief Set the OS clock interface and the logger + /// @brief Set the OS clock interface /// @param[in] f_osClock Access to the system clock (dependency injection possible in tests) - /// @param[in] f_logger_r Reference to the logger (dependency injection possible in tests) /// @param[in] f_watchdog watchdog implementation (dependency injection possible in tests) /// @param[in] f_process_state_receiver process state receiver implementation (dependency injection possible in tests) /* RULECHECKER_comment(3,1, check_expensive_to_copy_in_parameter, "Move only types cannot be passed by const ref", true_no_defect) */ - PhmDaemon(OsClock& f_osClock, Logger& f_logger_r, std::unique_ptr f_watchdog, - std::unique_ptr f_process_state_receiver); + PhmDaemon(OsClock& f_osClock, + std::unique_ptr f_watchdog, + std::unique_ptr f_process_state_receiver); /* RULECHECKER_comment(0, 4, check_min_instructions, "Default destructor is not provided\ a function body", true_no_defect) */ @@ -142,26 +139,26 @@ class PhmDaemon const int64_t timerInit{cycleTimer.init(cycleTimeModified)}; if (timerInit > 0) { - logger_r.LogInfo() << "Phm Daemon: The (configured) periodicity in [ns] is set to:" - << static_cast(cycleTimeModified); - logger_r.LogDebug() << "Phm Daemon: The accuracy of the monotonic system clock in [ns] is:" - << static_cast(CycleTimeValidator::getMonotonicClockAccuracy(osClock)); + LM_LOG_INFO() << "Phm Daemon: The (configured) periodicity in [ns] is set to:" + << static_cast(cycleTimeModified); + LM_LOG_DEBUG() << "Phm Daemon: The accuracy of the monotonic system clock in [ns] is:" + << static_cast(CycleTimeValidator::getMonotonicClockAccuracy(osClock)); } else { - logger_r.LogError() << "Phm Daemon: Initialization of CycleTimer instance failed!"; + LM_LOG_ERROR() << "Phm Daemon: Initialization of CycleTimer instance failed!"; return EInitCode::kCycleTimeInitFailed; } if (!watchdog->init(cycleTimeModified, machineConfig)) { - logger_r.LogError() << "Phm Daemon: Initialization of watchdog failed!"; + LM_LOG_ERROR() << "Phm Daemon: Initialization of watchdog failed!"; return EInitCode::kWatchdogInitFailed; } if (!watchdog->enable()) { - logger_r.LogError() << "Phm Daemon: Enabling of watchdog failed!"; + LM_LOG_ERROR() << "Phm Daemon: Enabling of watchdog failed!"; return EInitCode::kWatchdogEnableFailed; } @@ -194,7 +191,7 @@ class PhmDaemon NanoSecondType startTimestamp{cycleTimer.start()}; if (startTimestamp == 0U) { - logger_r.LogError() << "Phm Daemon: Failed to get initial timestamp"; + LM_LOG_ERROR() << "Phm Daemon: Failed to get initial timestamp"; return false; } @@ -216,26 +213,26 @@ class PhmDaemon const int sleepResult{cycleTimer.sleep(f_terminateCond, nsOverDeadline)}; if (sleepResult == EINTR) { - logger_r.LogInfo() << "Phm Daemon: Sleep was interrupted by termination signal"; + LM_LOG_INFO() << "Phm Daemon: Sleep was interrupted by termination signal"; break; } else if (sleepResult == CycleTimer::kDeadlineAlreadyOver) { - logger_r.LogDebug() << "Phm Daemon: Phm cycle took" - << (static_cast(nsOverDeadline) / 1000000.0 /*ns per ms*/) - << "ms longer than the configured cycle time"; + LM_LOG_DEBUG() << "Phm Daemon: Phm cycle took" + << (static_cast(nsOverDeadline) / 1000000.0 /*ns per ms*/) + << "ms longer than the configured cycle time"; } else if (sleepResult != 0) { - logger_r.LogError() << "Phm Daemon: Error during sleep system call, Code:" - << static_cast(sleepResult); + LM_LOG_ERROR() << "Phm Daemon: Error during sleep system call, Code:" + << static_cast(sleepResult); } else { /* sleeping successfully */ } } - logger_r.LogInfo() << "Phm Daemon: Received termination request - shutting down"; + LM_LOG_INFO() << "Phm Daemon: Received termination request - shutting down"; watchdog->disable(); return true; @@ -262,9 +259,6 @@ class PhmDaemon /// @brief For fixed time-step execution during the cyclic execution CycleTimer cycleTimer; - /// @brief Logging entity for warnings, errors used in init() phase and the cyclic() phase - Logger& logger_r; - /// @brief Recovery interface to Launch Manager std::shared_ptr recoveryClient; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.cpp index d183b7190..f59785cb0 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.cpp @@ -12,7 +12,7 @@ ********************************************************************************/ #include "score/mw/launch_manager/alive_monitor/details/daemon/SwClusterHandler.hpp" - +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/FlatCfgFactory.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/MonitorIfDaemon.hpp" @@ -28,8 +28,7 @@ namespace daemon { SwClusterHandler::SwClusterHandler(const std::string& f_swClusterName_r) - : logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::factory)), - f_swClusterName(f_swClusterName_r), + : f_swClusterName(f_swClusterName_r), processStates{}, aliveIfIpcs{}, aliveInterfaces{}, @@ -38,7 +37,7 @@ SwClusterHandler::SwClusterHandler(const std::string& f_swClusterName_r) { if (f_swClusterName_r.empty()) { - logger_r.LogError() << "Software Cluster Handler: Software cluster name is empty!"; + LM_LOG_ERROR() << "Software Cluster Handler: Software cluster name is empty!"; } } @@ -65,7 +64,7 @@ bool SwClusterHandler::constructWorkers( #endif if (isSuccess) { - logger_r.LogDebug() << "Software Cluster Handler starts constructing workers:" << f_swClusterName; + LM_LOG_DEBUG() << "Software Cluster Handler starts constructing workers:" << f_swClusterName; isSuccess = flatCfgFactory.createProcessStates(processStates, f_processStateReader_r); } if (isSuccess) @@ -87,7 +86,7 @@ bool SwClusterHandler::constructWorkers( } if (isSuccess == false) { - logger_r.LogError() << "Software Cluster Handler is unable to construct the required worker objects."; + LM_LOG_ERROR() << "Software Cluster Handler is unable to construct the required worker objects."; } return isSuccess; } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.hpp index 8306d697f..c5ce384fe 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/daemon/SwClusterHandler.hpp @@ -18,7 +18,6 @@ #include "score/mw/launch_manager/alive_monitor/details/ifappl/DataStructures.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessStateReader.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" #ifdef USE_NEW_CONFIGURATION #include "score/mw/launch_manager/configuration/config.hpp" @@ -122,9 +121,6 @@ class SwClusterHandler /// @param [in] f_syncTimestamp Timestamp for cyclic synchronization void evaluateSupervisions(const timers::NanoSecondType f_syncTimestamp); - /// @brief Logger - logging::PhmLogger& logger_r; - /// SwCluster Name for this SwCLusterHandler Object const std::string f_swClusterName; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/BUILD index 286ad86ad..c6d7c839f 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/BUILD @@ -53,10 +53,10 @@ cc_library( deps = [ ":static_config", "//score/launch_manager/src/daemon/src/alive_monitor/config", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:time_conversion", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", "//score/launch_manager/src/daemon/src/alive_monitor/details/watchdog:i_device_config_factory", + "//score/launch_manager/src/daemon/src/common:log", "@score_baselibs//score/flatbuffers:flatbufferscpp", "@score_baselibs//score/language/futurecpp", ] + select({ @@ -93,12 +93,12 @@ cc_library( "//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:monitor_if_daemon", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state_reader", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:alive", "//score/launch_manager/src/daemon/src/alive_monitor/details/supervision:supervision_cfg", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:time_conversion", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", "//score/launch_manager/src/daemon/src/common:identifier_hash", + "//score/launch_manager/src/daemon/src/common:log", "@score_baselibs//score/flatbuffers:flatbufferscpp", ] + select({ "//config:lm_use_new_configuration": [ diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.cpp index 13ae941a0..46f7c9f14 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.cpp @@ -17,17 +17,17 @@ #include #include -#include "score/mw/launch_manager/common/identifier_hash.hpp" +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/IPhmFactory.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/StaticConfig.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/MonitorIfDaemon.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/Alive.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/SupervisionCfg.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/TimeConversion.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" +#include "score/mw/launch_manager/common/identifier_hash.hpp" namespace score { @@ -73,11 +73,8 @@ std::unique_ptr read_flatbuffer_file(const std::string& f_filename_r) /* RULECHECKER_comment(0, 7, check_incomplete_data_member_construction, "Members processDataBase is not \ required to be initialized using member initializer list.", true_no_defect) */ FlatCfgFactory::FlatCfgFactory(const BufferConfig& f_bufferConfig_r) - : IPhmFactory(), - bufferConfig_r(f_bufferConfig_r), - flatBuffer_p(nullptr), - // loadBuffer_p(nullptr), - logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::factory)) + : IPhmFactory(), bufferConfig_r(f_bufferConfig_r), flatBuffer_p(nullptr) +// loadBuffer_p(nullptr) { static_cast(flatBuffer_p); } @@ -87,7 +84,7 @@ bool FlatCfgFactory::init(const std::string& f_filename_r) loadBuffer_p = read_flatbuffer_file(f_filename_r); if (!loadBuffer_p) { - logger_r.LogError() << kLogPrefix << "Could not open config file."; + LM_LOG_ERROR() << kLogPrefix << "Could not open config file."; return false; } @@ -95,7 +92,7 @@ bool FlatCfgFactory::init(const std::string& f_filename_r) flatBuffer_p = HMFlatBuffer::GetHMEcuCfg(loadBuffer_p.get()); if (flatBuffer_p == nullptr) { - logger_r.LogError() << kLogPrefix << "Reading HealthMonitor configuration from FlatCfg failed."; + LM_LOG_ERROR() << kLogPrefix << "Reading HealthMonitor configuration from FlatCfg failed."; return false; } return true; @@ -149,14 +146,14 @@ bool FlatCfgFactory::createProcessStates(std::vector& f_pro } const std::string processShortNameRead{f_processStates_r.back().getConfigName()}; - logger_r.LogDebug() << kLogPrefix << "Successfully created Process States:" << processShortNameRead; + LM_LOG_DEBUG() << kLogPrefix << "Successfully created Process States:" << processShortNameRead; } } catch (const std::exception& f_exception_r) { isSuccess = false; - logger_r.LogError() << kLogPrefix << "Could not create Process States due to exception:" - << std::string_view{f_exception_r.what()}; + LM_LOG_ERROR() << kLogPrefix << "Could not create Process States due to exception:" + << std::string_view{f_exception_r.what()}; } } else @@ -166,8 +163,8 @@ bool FlatCfgFactory::createProcessStates(std::vector& f_pro if (isSuccess) { - logger_r.LogDebug() << kLogPrefix << "Number of constructed Process States:" - << static_cast(f_processStates_r.size()); + LM_LOG_DEBUG() << kLogPrefix + << "Number of constructed Process States:" << static_cast(f_processStates_r.size()); } else { @@ -177,7 +174,7 @@ bool FlatCfgFactory::createProcessStates(std::vector& f_pro f_processStateReader_r.deregisterProcessState(processState_r.getProcessId()); } f_processStates_r.clear(); - logger_r.LogError() << kLogPrefix << "Could not create all necessary Process States."; + LM_LOG_ERROR() << kLogPrefix << "Could not create all necessary Process States."; } return isSuccess; @@ -200,8 +197,8 @@ bool FlatCfgFactory::initIpcServerWithUidBasedAccess(ifappl::CheckpointIpcServer const uid_t uid = static_cast(f_uid); if (!f_ipcServer_r.setAccessRights(uid)) { - logger_r.LogError() << kLogPrefix << "Could not set ACL permissions (r/w for uid" << uid - << ") for Alive interface IPC with path:" << f_ipcPath_r; + LM_LOG_ERROR() << kLogPrefix << "Could not set ACL permissions (r/w for uid" << uid + << ") for Alive interface IPC with path:" << f_ipcPath_r; return false; } return true; @@ -227,13 +224,12 @@ bool FlatCfgFactory::createAliveIfIpcs(std::vector& if (isSuccess) { - logger_r.LogDebug() << kLogPrefix - << "Successfully created Alive interface IPC with path:" << pathInterface; + LM_LOG_DEBUG() << kLogPrefix + << "Successfully created Alive interface IPC with path:" << pathInterface; } else { - logger_r.LogError() << kLogPrefix - << "Could not create Alive interface IPC with path:" << pathInterface; + LM_LOG_ERROR() << kLogPrefix << "Could not create Alive interface IPC with path:" << pathInterface; break; } } @@ -241,33 +237,33 @@ bool FlatCfgFactory::createAliveIfIpcs(std::vector& catch (const std::exception& f_exception_r) { isSuccess = false; - logger_r.LogError() << kLogPrefix << "Could not create Alive interface IPC due to exception:" - << std::string_view{f_exception_r.what()}; + LM_LOG_ERROR() << kLogPrefix << "Could not create Alive interface IPC due to exception:" + << std::string_view{f_exception_r.what()}; } } else { isSuccess = false; - logger_r.LogError() << kLogPrefix << "Could not create Alive interface IPCs due to missing configuration"; + LM_LOG_ERROR() << kLogPrefix << "Could not create Alive interface IPCs due to missing configuration"; } if (isSuccess) { - logger_r.LogDebug() << kLogPrefix << "Number of constructed Alive interface IPCs:" - << static_cast(f_interfaceIpcs_r.size()); + LM_LOG_DEBUG() << kLogPrefix << "Number of constructed Alive interface IPCs:" + << static_cast(f_interfaceIpcs_r.size()); } else { f_interfaceIpcs_r.clear(); - logger_r.LogError() << kLogPrefix << "Could not create all necessary Alive interface IPCs."; + LM_LOG_ERROR() << kLogPrefix << "Could not create all necessary Alive interface IPCs."; } return isSuccess; } bool FlatCfgFactory::createAliveIf(std::vector& f_interfaces_r, - std::vector& f_interfaceIpcs_r, - std::vector& f_processStates_r) + std::vector& f_interfaceIpcs_r, + std::vector& f_processStates_r) { bool isSuccess{true}; try @@ -286,21 +282,21 @@ bool FlatCfgFactory::createAliveIf(std::vector& f_inter f_processStates_r.at(static_cast(refProcessIndex)).attachObserver(f_interfaces_r.back()); - logger_r.LogDebug() << kLogPrefix - << "Successfully created Alive Interface:" << f_interfaces_r.back().getInterfaceName(); + LM_LOG_DEBUG() << kLogPrefix + << "Successfully created Alive Interface:" << f_interfaces_r.back().getInterfaceName(); // coverity[autosar_cpp14_a4_7_1_violation] Value limited by amount of interfaces, which is smaller. index++; } - logger_r.LogDebug() << kLogPrefix << "Number of constructed Alive interfaces:" - << static_cast(f_interfaces_r.size()); + LM_LOG_DEBUG() << kLogPrefix + << "Number of constructed Alive interfaces:" << static_cast(f_interfaces_r.size()); } catch (const std::exception& f_exception_r) { isSuccess = false; f_interfaces_r.clear(); - logger_r.LogError() << kLogPrefix << "Could not create all necessary Alive interfaces due to exception:" - << std::string_view{f_exception_r.what()}; + LM_LOG_ERROR() << kLogPrefix << "Could not create all necessary Alive interfaces due to exception:" + << std::string_view{f_exception_r.what()}; } return isSuccess; @@ -336,15 +332,15 @@ bool FlatCfgFactory::createSupervisionCheckpoints(std::vector(f_checkpoints_r.size()); + LM_LOG_DEBUG() << kLogPrefix << "Number of constructed supervision checkpoints:" + << static_cast(f_checkpoints_r.size()); } else { f_checkpoints_r.clear(); - logger_r.LogError() << kLogPrefix << "Could not create all necessary supervision checkpoints."; + LM_LOG_ERROR() << kLogPrefix << "Could not create all necessary supervision checkpoints."; } return isSuccess; @@ -421,36 +417,35 @@ bool FlatCfgFactory::createAliveSupervisions(std::vector& f_ // Subscribe created Alive Supervision to ProcessState class f_processStates_r.at(static_cast(processIndex)).attachObserver(f_alive_r.back()); - logger_r.LogDebug() << kLogPrefix << "Successfully created alive supervision worker object:" - << f_alive_r.back().getConfigName(); + LM_LOG_DEBUG() << kLogPrefix << "Successfully created alive supervision worker object:" + << f_alive_r.back().getConfigName(); } } catch (const std::exception& f_exception_r) { isSuccess = false; - logger_r.LogError() << kLogPrefix - << "Could not create all necessary alive supervision " - "worker objects, due to exception:" - << std::string_view{f_exception_r.what()}; + LM_LOG_ERROR() << kLogPrefix + << "Could not create all necessary alive supervision " + "worker objects, due to exception:" + << std::string_view{f_exception_r.what()}; } } if (isSuccess) { - logger_r.LogDebug() << kLogPrefix - << "Number of constructed alive supervisions:" << static_cast(f_alive_r.size()); + LM_LOG_DEBUG() << kLogPrefix + << "Number of constructed alive supervisions:" << static_cast(f_alive_r.size()); } else { f_alive_r.clear(); - logger_r.LogError() << kLogPrefix << "Could not create all necessary alive supervision worker objects"; + LM_LOG_ERROR() << kLogPrefix << "Could not create all necessary alive supervision worker objects"; } return isSuccess; } -std::optional FlatCfgFactory::getProcessId(const std::string& f_processPath_r) noexcept( - true) +std::optional FlatCfgFactory::getProcessId(const std::string& f_processPath_r) noexcept(true) { return score::lcm::IdentifierHash{f_processPath_r}.data(); } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.hpp index a2ffea323..c3711b23b 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory.hpp @@ -43,11 +43,6 @@ namespace lcm namespace saf { -namespace logging -{ -class PhmLogger; -} - namespace factory { @@ -146,9 +141,6 @@ class FlatCfgFactory : public IPhmFactory /// Pointer for loaded Software Cluster std::unique_ptr loadBuffer_p; #endif - - /// Logger object for logging messages - logging::PhmLogger& logger_r; }; } // namespace factory diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory_new.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory_new.cpp index 125a05f00..75efbc39c 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory_new.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/FlatCfgFactory_new.cpp @@ -17,12 +17,12 @@ #include #include +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/IPhmFactory.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/StaticConfig.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/MonitorIfDaemon.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/Alive.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/SupervisionCfg.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/TimeConversion.hpp" @@ -54,9 +54,7 @@ bool isSupervisedType(ApplicationType app_type) { FlatCfgFactory::FlatCfgFactory( const BufferConfig &f_bufferConfig_r) - : IPhmFactory(), bufferConfig_r(f_bufferConfig_r), config_(nullptr), - logger_r(logging::PhmLogger::getLogger( - logging::PhmLogger::EContext::factory)) {} + : IPhmFactory(), bufferConfig_r(f_bufferConfig_r), config_(nullptr) {} bool FlatCfgFactory::init(const Config &config) { config_ = &config; @@ -93,17 +91,17 @@ bool FlatCfgFactory::createProcessStates( break; } - logger_r.LogDebug() << "Successfully created Process States:" + LM_LOG_DEBUG() << "Successfully created Process States:" << comp->name; } } catch (const std::exception &f_exception_r) { isSuccess = false; - logger_r.LogError() << "Could not create Process States due to exception:" + LM_LOG_ERROR() << "Could not create Process States due to exception:" << std::string_view{f_exception_r.what()}; } if (isSuccess) { - logger_r.LogDebug() << "Number of constructed Process States:" + LM_LOG_DEBUG() << "Number of constructed Process States:" << static_cast(f_processStates_r.size()); } else { for (auto &processState_r : f_processStates_r) { @@ -111,7 +109,7 @@ bool FlatCfgFactory::createProcessStates( processState_r.getProcessId()); } f_processStates_r.clear(); - logger_r.LogError() << "Could not create all necessary Process States."; + LM_LOG_ERROR() << "Could not create all necessary Process States."; } return isSuccess; @@ -128,7 +126,7 @@ bool FlatCfgFactory::initIpcServerWithUidBasedAccess( const uid_t uid = static_cast(f_uid); if (!f_ipcServer_r.setAccessRights(uid)) { - logger_r.LogError() << "Could not set ACL permissions (r/w for uid" << uid + LM_LOG_ERROR() << "Could not set ACL permissions (r/w for uid" << uid << ") for Monitor interface IPC with path:" << f_ipcPath_r; return false; @@ -152,11 +150,11 @@ bool FlatCfgFactory::createAliveIfIpcs( pathInterface, configuredUid); if (isSuccess) { - logger_r.LogDebug() + LM_LOG_DEBUG() << "Successfully created Monitor interface IPC with path:" << pathInterface; } else { - logger_r.LogError() + LM_LOG_ERROR() << "Could not create Monitor interface IPC with path:" << pathInterface; break; @@ -164,17 +162,17 @@ bool FlatCfgFactory::createAliveIfIpcs( } } catch (const std::exception &f_exception_r) { isSuccess = false; - logger_r.LogError() + LM_LOG_ERROR() << "Could not create Monitor interface IPC due to exception:" << std::string_view{f_exception_r.what()}; } if (isSuccess) { - logger_r.LogDebug() << "Number of constructed Monitor interface IPCs:" + LM_LOG_DEBUG() << "Number of constructed Monitor interface IPCs:" << static_cast(f_interfaceIpcs_r.size()); } else { f_interfaceIpcs_r.clear(); - logger_r.LogError() + LM_LOG_ERROR() << "Could not create all necessary Monitor interface IPCs."; } @@ -194,16 +192,16 @@ bool FlatCfgFactory::createAliveIf( f_interfaces_r.emplace_back(interfaceIpc, interfaceIpc.getPath().data()); f_processStates_r.at(compIndex).attachObserver(f_interfaces_r.back()); - logger_r.LogDebug() << "Successfully created MonitorInterface:" + LM_LOG_DEBUG() << "Successfully created MonitorInterface:" << f_interfaces_r.back().getInterfaceName(); } - logger_r.LogDebug() << "Number of constructed Monitor interfaces:" + LM_LOG_DEBUG() << "Number of constructed Monitor interfaces:" << static_cast(f_interfaces_r.size()); } catch (const std::exception &f_exception_r) { isSuccess = false; f_interfaces_r.clear(); - logger_r.LogError() + LM_LOG_ERROR() << "Could not create all necessary Monitor interfaces due to exception:" << std::string_view{f_exception_r.what()}; } @@ -230,22 +228,22 @@ bool FlatCfgFactory::createSupervisionCheckpoints( process_p); f_interfaces_r.at(idx).attachCheckpoint(f_checkpoints_r.back()); - logger_r.LogDebug() << "Successfully created supervision checkpoint:" + LM_LOG_DEBUG() << "Successfully created supervision checkpoint:" << f_checkpoints_r.back().getConfigName(); } } catch (const std::exception &f_exception_r) { isSuccess = false; - logger_r.LogError() + LM_LOG_ERROR() << "Could not create supervision worker objects, due to exception:" << std::string_view{f_exception_r.what()}; } if (isSuccess) { - logger_r.LogDebug() << "Number of constructed supervision checkpoints:" + LM_LOG_DEBUG() << "Number of constructed supervision checkpoints:" << static_cast(f_checkpoints_r.size()); } else { f_checkpoints_r.clear(); - logger_r.LogError() + LM_LOG_ERROR() << "Could not create all necessary supervision checkpoints."; } @@ -300,23 +298,23 @@ bool FlatCfgFactory::createAliveSupervisions( f_processStates_r.at(idx).attachObserver(f_alive_r.back()); - logger_r.LogDebug() + LM_LOG_DEBUG() << "Successfully created alive supervision worker object:" << f_alive_r.back().getConfigName(); } } catch (const std::exception &f_exception_r) { isSuccess = false; - logger_r.LogError() << "Could not create all necessary alive supervision " + LM_LOG_ERROR() << "Could not create all necessary alive supervision " "worker objects, due to exception:" << std::string_view{f_exception_r.what()}; } if (isSuccess) { - logger_r.LogDebug() << "Number of constructed alive supervisions:" + LM_LOG_DEBUG() << "Number of constructed alive supervisions:" << static_cast(f_alive_r.size()); } else { f_alive_r.clear(); - logger_r.LogError() + LM_LOG_ERROR() << "Could not create all necessary alive supervision worker objects"; } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.cpp index fa4a69e44..380d52fa4 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.cpp @@ -17,6 +17,7 @@ #include #include "flatbuffers/flatbuffers.h" +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/config/hmcore_flatcfg_generated.h" #include "score/mw/launch_manager/alive_monitor/details/timers/TimeConversion.hpp" #include @@ -82,7 +83,7 @@ bool MachineConfigFactory::init() noexcept(false) std::unique_ptr loadBuffer_p = read_flatbuffer_file("hmcore.bin"); if (!loadBuffer_p) { - logger_r.LogInfo() << kLogPrefix << "No HM Machine Configuration found. Using default configuration."; + LM_LOG_INFO() << kLogPrefix << "No HM Machine Configuration found. Using default configuration."; logConfiguration(); return true; } @@ -91,7 +92,7 @@ bool MachineConfigFactory::init() noexcept(false) flatBuffer_p = HMCOREFlatBuffer::GetHMCOREEcuCfg(loadBuffer_p.get()); if (flatBuffer_p == nullptr) { - logger_r.LogError() << kLogPrefix << "Reading HM configuration from FlatCfg failed."; + LM_LOG_ERROR() << kLogPrefix << "Reading HM configuration from FlatCfg failed."; return false; } @@ -103,7 +104,7 @@ bool MachineConfigFactory::loadHmCoreConfig(const HMCoreEcuCfg* f_cfg_r) noexcep { loadHmSettings(*f_cfg_r); loadWatchdogDevices(*f_cfg_r); - logger_r.LogInfo() << kLogPrefix << "Loading of HM Machine Configuration succeeded."; + LM_LOG_INFO() << kLogPrefix << "Loading of HM Machine Configuration succeeded."; logConfiguration(); return true; } @@ -159,10 +160,10 @@ void MachineConfigFactory::loadHmSettings(const HMCoreEcuCfg& f_flatBuffer_r) no if (supBufferCfg.bufferSizeMonitor != StaticConfig::k_DefaultMonitorBufferElements) { supBufferCfg.bufferSizeMonitor = StaticConfig::k_DefaultMonitorBufferElements; - logger_r.LogWarn() << kLogPrefix - << "Configuring Supervised Entity buffer size from machine config is currently not " - "supported. Using default buffer size of" - << StaticConfig::k_DefaultMonitorBufferElements << "checkpoints"; + LM_LOG_WARN() << kLogPrefix + << "Configuring Supervised Entity buffer size from machine config is currently not " + "supported. Using default buffer size of" + << StaticConfig::k_DefaultMonitorBufferElements << "checkpoints"; } } } @@ -187,20 +188,19 @@ void MachineConfigFactory::logConfiguration() noexcept(true) { /* RULECHECKER_comment(0, 18, check_conditional_as_sub_expression, "Ternary operation is very simple", * true_no_defect) */ - logger_r.LogDebug() << kLogPrefix << "Alive Supervision buffer size:" << supBufferCfg.bufferSizeAliveSupervision; - logger_r.LogDebug() << kLogPrefix << "Monitor buffer size:" << supBufferCfg.bufferSizeMonitor; - logger_r.LogDebug() << kLogPrefix << "Periodicity:" << getCycleTimeInNs() << "ns"; - logger_r.LogDebug() << kLogPrefix << "Configured watchdogs:" << watchdogConfigs.size(); + LM_LOG_DEBUG() << kLogPrefix << "Alive Supervision buffer size:" << supBufferCfg.bufferSizeAliveSupervision; + LM_LOG_DEBUG() << kLogPrefix << "Monitor buffer size:" << supBufferCfg.bufferSizeMonitor; + LM_LOG_DEBUG() << kLogPrefix << "Periodicity:" << getCycleTimeInNs() << "ns"; + LM_LOG_DEBUG() << kLogPrefix << "Configured watchdogs:" << watchdogConfigs.size(); std::uint32_t wdgCount{1U}; for (const auto& wdgConfig : watchdogConfigs) { const std::string_view wdgMagicCloseBool{wdgConfig.needsMagicClose ? "true" : "false"}; const std::string_view wdgDeactivatedBool{wdgConfig.canBeDeactivated ? "true" : "false"}; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- device file:" << wdgConfig.fileName; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- max timeout:" << wdgConfig.timeoutMax << "ms"; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- needs magic close:" << wdgMagicCloseBool; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount - << "- deactivate on hm shutdown:" << wdgDeactivatedBool; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- device file:" << wdgConfig.fileName; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- max timeout:" << wdgConfig.timeoutMax << "ms"; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- needs magic close:" << wdgMagicCloseBool; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- deactivate on hm shutdown:" << wdgDeactivatedBool; // coverity[autosar_cpp14_a4_7_1_violation] Value limited by amount of watchdog configurations, which is // smaller. ++wdgCount; @@ -208,7 +208,7 @@ void MachineConfigFactory::logConfiguration() noexcept(true) if (watchdogConfigs.empty()) { - logger_r.LogWarn() << kLogPrefix << "No watchdog configured"; + LM_LOG_WARN() << kLogPrefix << "No watchdog configured"; } } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.hpp index 67a8a1902..6254295b7 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory.hpp @@ -17,7 +17,6 @@ #include #include "score/mw/launch_manager/alive_monitor/details/factory/StaticConfig.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" #include "score/mw/launch_manager/alive_monitor/details/watchdog/IDeviceConfigFactory.hpp" #ifdef USE_NEW_CONFIGURATION @@ -37,11 +36,6 @@ namespace lcm namespace saf { -namespace logging -{ -class PhmLogger; -} - namespace factory { @@ -133,9 +127,6 @@ class MachineConfigFactory : public watchdog::IDeviceConfigFactory /// Raw pointer is used here because the memory is deallocated by FlatBuffer. const HMCOREFlatBuffer::HMCOREEcuCfg* flatBuffer_p; #endif - - /// Logger object for logging messages - logging::PhmLogger& logger_r{logging::PhmLogger::getLogger(logging::PhmLogger::EContext::factory)}; }; } // namespace factory diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory_new.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory_new.cpp index a870df1af..e9544600c 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory_new.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/factory/MachineConfigFactory_new.cpp @@ -10,6 +10,7 @@ * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/factory/MachineConfigFactory.hpp" #include @@ -57,7 +58,7 @@ bool MachineConfigFactory::init(const Config& config) noexcept(false) watchdogConfigs.push_back(std::move(wdConfig)); } - logger_r.LogInfo() << kLogPrefix << "Loading of HM Machine Configuration succeeded."; + LM_LOG_INFO() << kLogPrefix << "Loading of HM Machine Configuration succeeded."; logConfiguration(); return true; } @@ -80,26 +81,25 @@ const MachineConfigFactory::SupervisionBufferConfig& MachineConfigFactory::getSu void MachineConfigFactory::logConfiguration() noexcept(true) { - logger_r.LogDebug() << kLogPrefix << "Alive Supervision buffer size:" << supBufferCfg.bufferSizeAliveSupervision; - logger_r.LogDebug() << kLogPrefix << "Monitor buffer size:" << supBufferCfg.bufferSizeMonitor; - logger_r.LogDebug() << kLogPrefix << "Periodicity:" << getCycleTimeInNs() << "ns"; - logger_r.LogDebug() << kLogPrefix << "Configured watchdogs:" << watchdogConfigs.size(); + LM_LOG_DEBUG() << kLogPrefix << "Alive Supervision buffer size:" << supBufferCfg.bufferSizeAliveSupervision; + LM_LOG_DEBUG() << kLogPrefix << "Monitor buffer size:" << supBufferCfg.bufferSizeMonitor; + LM_LOG_DEBUG() << kLogPrefix << "Periodicity:" << getCycleTimeInNs() << "ns"; + LM_LOG_DEBUG() << kLogPrefix << "Configured watchdogs:" << watchdogConfigs.size(); std::uint32_t wdgCount{1U}; for (const auto& wdgConfig : watchdogConfigs) { const std::string_view wdgMagicCloseBool{wdgConfig.needsMagicClose ? "true" : "false"}; const std::string_view wdgDeactivatedBool{wdgConfig.canBeDeactivated ? "true" : "false"}; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- device file:" << wdgConfig.fileName; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- max timeout:" << wdgConfig.timeoutMax << "ms"; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount << "- needs magic close:" << wdgMagicCloseBool; - logger_r.LogDebug() << kLogPrefix << "Watchdog" << wdgCount - << "- deactivate on hm shutdown:" << wdgDeactivatedBool; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- device file:" << wdgConfig.fileName; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- max timeout:" << wdgConfig.timeoutMax << "ms"; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- needs magic close:" << wdgMagicCloseBool; + LM_LOG_DEBUG() << kLogPrefix << "Watchdog" << wdgCount << "- deactivate on hm shutdown:" << wdgDeactivatedBool; ++wdgCount; } if (watchdogConfigs.empty()) { - logger_r.LogWarn() << kLogPrefix << "No watchdog configured"; + LM_LOG_WARN() << kLogPrefix << "No watchdog configured"; } } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/BUILD index 32c531645..1728f5a8c 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/BUILD @@ -52,7 +52,6 @@ cc_library( ":checkpoint", ":data_structures", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", ], ) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.cpp index 6224e4fa3..1640908c5 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.cpp @@ -15,6 +15,7 @@ #include +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" namespace score @@ -26,11 +27,8 @@ namespace saf namespace ifappl { -MonitorIfDaemon::MonitorIfDaemon(CheckpointIpcServer& f_ipcServer_r, const char* f_interfaceName_p) : - Observer(), - k_interfaceName(f_interfaceName_p), - ipcserver_r(f_ipcServer_r), - logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::supervision)) +MonitorIfDaemon::MonitorIfDaemon(CheckpointIpcServer& f_ipcServer_r, const char* f_interfaceName_p) + : Observer(), k_interfaceName(f_interfaceName_p), ipcserver_r(f_ipcServer_r) { } @@ -126,8 +124,8 @@ void MonitorIfDaemon::checkForNewData(const timers::NanoSecondType f_syncTimesta void MonitorIfDaemon::handleOverflow() { - logger_r.LogWarn() << "MonitorInterface: Potential data loss of checkpoint ring buffer occurred." - << "Instance:" << k_interfaceName; + LM_LOG_WARN() << "MonitorInterface: Potential data loss of checkpoint ring buffer occurred." + << "Instance:" << k_interfaceName; pushOverflowInfoToCheckpointObservers(); status = EInternalState::kInactiveOverflow; } @@ -193,8 +191,8 @@ bool MonitorIfDaemon::pushNewDataToCheckpointObservers(const timers::NanoSecondT if (amountOfReceivedCheckpoints > 0U) { - //logger_r.LogDebug() << "MonitorInterface: Amount of checkpoints in buffer:" - // << amountOfReceivedCheckpoints << "Instance" << k_interfaceName; + // LM_LOG_DEBUG() << "MonitorInterface: Amount of checkpoints in buffer:" + // << amountOfReceivedCheckpoints << "Instance" << k_interfaceName; } return success; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.hpp index ec2d7205a..b177634b1 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon.hpp @@ -18,7 +18,6 @@ #include #include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/DataStructures.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" namespace score @@ -154,9 +153,6 @@ class MonitorIfDaemon : public common::Observer /// @brief IPC connection to application CheckpointIpcServer& ipcserver_r; - - /// Logger - logging::PhmLogger& logger_r; }; } // namespace ifappl diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/BUILD index 9e3c1836f..71fa23382 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/BUILD @@ -50,9 +50,9 @@ cc_library( deps = [ ":process_state", "//score/launch_manager/src/daemon/src/alive_monitor/details/common:types", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:time_conversion", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", + "//score/launch_manager/src/daemon/src/common:log", "//score/launch_manager/src/daemon/src/process_state_client", ], ) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.cpp index bd2593d15..064c03dda 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.cpp @@ -12,7 +12,7 @@ ********************************************************************************/ #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessStateReader.hpp" - +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/TimeConversion.hpp" namespace score @@ -24,9 +24,8 @@ namespace saf namespace ifexm { -ProcessStateReader::ProcessStateReader(std::unique_ptr f_process_state_receiver) : - processStateReceiverHM(std::move(f_process_state_receiver)), - logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::supervision)) +ProcessStateReader::ProcessStateReader(std::unique_ptr f_process_state_receiver) + : processStateReceiverHM(std::move(f_process_state_receiver)) { } @@ -41,7 +40,7 @@ bool ProcessStateReader::registerProcessState(ProcessState& f_processState_r, if (!flagSuccess) { - logger_r.LogError() << "Process State Reader did not register" << f_processState_r.getConfigName(); + LM_LOG_ERROR() << "Process State Reader did not register" << f_processState_r.getConfigName(); } return flagSuccess; @@ -79,9 +78,9 @@ bool ProcessStateReader::distributeChanges(const timers::NanoSecondType f_syncTi const auto changedPosixProcess{resultChangedProcess.value()}; if (changedPosixProcess) { - logger_r.LogDebug() << "Process with Id" << changedPosixProcess->id << "changed state PG" - << changedPosixProcess->processGroupStateId << "PS" - << static_cast(changedPosixProcess->processStateId); + LM_LOG_DEBUG() << "Process with Id" << changedPosixProcess->id << "changed state PG" + << changedPosixProcess->processGroupStateId << "PS" + << static_cast(changedPosixProcess->processStateId); isPushPending = pushUpdateTill(*changedPosixProcess, f_syncTimestamp); flagContinue = (!isPushPending); } @@ -93,7 +92,7 @@ bool ProcessStateReader::distributeChanges(const timers::NanoSecondType f_syncTi } else { - logger_r.LogError() << "Process State Reader failed with error:" << resultChangedProcess.error().Message(); + LM_LOG_ERROR() << "Process State Reader failed with error:" << resultChangedProcess.error().Message(); flagContinue = false; flagSuccess = false; } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.hpp index 75db72899..dc8b44a43 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/ifexm/ProcessStateReader.hpp @@ -18,7 +18,6 @@ #include "score/mw/launch_manager/alive_monitor/details/common/Types.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" #include "score/mw/launch_manager/process_state_client/posix_process.hpp" #include "score/mw/launch_manager/process_state_client/iprocess_state_receiver.hpp" @@ -89,9 +88,6 @@ class ProcessStateReader /// @brief Process state receiver for HM thread std::unique_ptr processStateReceiverHM; - /// @brief Logger - logging::PhmLogger& logger_r; - /// @brief Map for process id and process state object std::map processStateMap{}; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/logging/BUILD deleted file mode 100644 index 0a0547059..000000000 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/BUILD +++ /dev/null @@ -1,30 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation -# -# See the NOTICE file(s) distributed with this work for additional -# information regarding copyright ownership. -# -# This program and the accompanying materials are made available under the -# terms of the Apache License Version 2.0 which is available at -# https://www.apache.org/licenses/LICENSE-2.0 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* -load("@rules_cc//cc:defs.bzl", "cc_library") - -cc_library( - name = "phm_logging", - srcs = ["PhmLogger.cpp"], - hdrs = ["PhmLogger.hpp"], - defines = select({ - "//config:lm_use_cout_log": [], - "//conditions:default": ["LC_LOG_SCORE_MW_LOG"], - }), - include_prefix = "score/mw/launch_manager/alive_monitor/details/logging", - strip_include_prefix = "/score/launch_manager/src/daemon/src/alive_monitor/details/logging", - visibility = [ - "//score/launch_manager/src/alive:__subpackages__", - "//score/launch_manager/src/daemon/src/alive_monitor:__subpackages__", - ], - deps = ["@score_baselibs//score/mw/log"], -) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.cpp deleted file mode 100644 index 1f1e9201c..000000000 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -#include - -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" - -namespace score -{ -namespace lcm -{ -namespace saf -{ -namespace logging -{ - -#ifdef LC_LOG_SCORE_MW_LOG - -PhmLogger::PhmLogger(std::string_view f_context, std::string_view f_description) noexcept(true) - : logger_r(score::mw::log::CreateLogger(f_context, f_description)) -{ -} - -#else // LC_LOG_SCORE_MW_LOG - -PhmLogger::PhmLogger(std::string_view f_context, std::string_view f_description) noexcept(true) - : logger_r(f_context, f_description) -{ -} - -#endif // LC_LOG_SCORE_MW_LOG - -/* RULECHECKER_comment(0, 10, check_static_object_dynamic_initialization, "PhmLogger object is initialized\ - with static qualifier for singleton access", true_low) */ -/* RULECHECKER_comment(0, 30, check_switch_clause_break_return, "Singleton object is returned as part of \ -the switch case evaluation", true_low) */ -PhmLogger& PhmLogger::getLogger(const EContext f_context) noexcept(true) -{ - static PhmLogger factoryLogger{"Fcty", "Context for error/info logging from PHM Factory"}; - static PhmLogger supervisionLogger{"Sprv", "Context for error/info logging from PHM Supervision"}; - static PhmLogger recoveryLogger{"Rcvy", "Context for error/info logging from PHM Recovery"}; - static PhmLogger watchdogLogger{"Wdg", "Context for error/info logging from PHM Watchdog"}; - - switch (f_context) - { - case EContext::factory: - { - return factoryLogger; - } - case EContext::supervision: - { - return supervisionLogger; - } - case EContext::recovery: - { - return recoveryLogger; - } - case EContext::watchdog: - { - return watchdogLogger; - } - default: - { - // Always return a working logger - return supervisionLogger; - } - } -} - -Stream PhmLogger::LogFatal() noexcept -{ - return logger_r.LogFatal(); -} - -Stream PhmLogger::LogError() noexcept -{ - return logger_r.LogError(); -} - -Stream PhmLogger::LogWarn() noexcept -{ - return logger_r.LogWarn(); -} - -Stream PhmLogger::LogInfo() noexcept -{ - return logger_r.LogInfo(); -} - -Stream PhmLogger::LogDebug() noexcept -{ - return logger_r.LogDebug(); -} - -Stream PhmLogger::LogVerbose() noexcept -{ - return logger_r.LogVerbose(); -} - -} // namespace logging -} // namespace saf -} // namespace lcm -} // namespace score diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.hpp deleted file mode 100644 index aa9154e15..000000000 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/logging/PhmLogger.hpp +++ /dev/null @@ -1,299 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2025 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - - -#ifndef PHMLOGGER_HPP_INCLUDED -#define PHMLOGGER_HPP_INCLUDED - -#include - -#ifdef LC_LOG_SCORE_MW_LOG -#include "score/mw/log/logger.h" -#include "score/mw/log/log_stream.h" -#else -#include -#include -#include -#include -#include -#endif - - -namespace score -{ -namespace lcm -{ -namespace saf -{ -namespace logging -{ - -#ifdef LC_LOG_SCORE_MW_LOG - -using Stream = score::mw::log::LogStream; -using Logger = score::mw::log::Logger; - -#else // LC_LOG_SCORE_MW_LOG - -enum class LogLevel -{ - kFatal = 0, - kError = 1, - kWarn = 2, - kInfo = 3, - kDebug = 4, - kVerbose = 5, -}; - -inline LogLevel GetLevelFromEnv() { - if (const char* levelStr = std::getenv("LC_STDOUT_LOG_LEVEL")) { - std::string_view levelSv{levelStr}; - int logLevelTmp; - try { - logLevelTmp = std::stoi(levelSv.data()); - }catch(...) { - return LogLevel::kInfo; - } - - if(logLevelTmp >= static_cast(LogLevel::kFatal) && logLevelTmp <= static_cast(LogLevel::kVerbose)) { - return LogLevel(logLevelTmp); - } else { - return LogLevel::kInfo; - } - - } else { - return LogLevel::kInfo; - } -} - -static LogLevel GetLevel() { - const static LogLevel logLevel = GetLevelFromEnv(); - return logLevel; -} - -inline std::ostream& operator<<(std::ostream& os, const std::tm* now ) { - std::cout << (now->tm_year + 1900) << '/' - << (now->tm_mon + 1) << '/' - << now->tm_mday << " " - << now->tm_hour << ":" - << now->tm_min << ":" - << now->tm_sec; - return os; -} - -class Stream -{ -public: - Stream() noexcept = default; - Stream(const Stream &) = delete; - Stream(Stream && other) noexcept { - print_ = other.print_; - moved_ = true; - }; - - void SetPrint() { - print_ = true; - } - - template - Stream& operator<<(const T* value) noexcept - { - - if(print_) - std::cout << " " << value; - return *this; - } - - template - Stream& operator<<(const T& value) noexcept - { - if(print_) - std::cout << " " << value; - return *this; - } - - ~Stream() - { - if(print_ && moved_) - std::cout << " ]" << reset_color_ << std::endl; - } -private: - bool print_{false}; - bool moved_{false}; - std::string_view reset_color_{"\033[0m"}; -}; - -class Logger -{ -public: - Logger(std::string_view f_context, std::string_view f_description) : - ctxId_(f_context), ctxDescription_{f_description} { - - } - - Stream LogFatal() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kFatal) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << check_it_ << text_color_ << now << appId_ << ctxId_ << "FATAL: ["; - } - return std::move(stream); - } - - Stream LogError() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kError) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << check_it_ << text_color_ << now << appId_ << ctxId_ << "ERROR: ["; - } - - return std::move(stream); - } - - Stream LogWarn() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kWarn) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << check_it_ << text_color_ << now << appId_ << ctxId_ << "WARNING: ["; - } - return std::move(stream); - } - - Stream LogInfo() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kInfo) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << text_color_ << now << appId_ << ctxId_ << "INFO: ["; - } - return std::move(stream); - } - - Stream LogDebug() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kDebug) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << text_color_ << now << appId_ << ctxId_ << "DEBUG: ["; - } - return std::move(stream); - } - - Stream LogVerbose() noexcept - { - Stream stream; - if(GetLevel() >= LogLevel::kVerbose) { - stream.SetPrint(); - std::time_t t = std::time(0); - std::tm* now = std::localtime(&t); - stream << text_color_ << now << appId_ << ctxId_ << "VERBOSE: ["; - } - return std::move(stream); - } -private: - const std::string_view appId_{"LCHM"}; - const std::string_view ctxId_{"####"}; - const std::string_view ctxDescription_{"####"}; - const std::string_view text_color_{"\033[0;32m"}; - const std::string_view check_it_{"\033[101;30m !!! -> \033[0m"}; -}; - -#endif // LC_LOG_SCORE_MW_LOG - -/// @brief Phm Logging Adapter -/// @details This class is a thin adaptor to score::mw::log::Logger to centrally adapt potential API changes of the Logger -/// class. -class PhmLogger -{ -public: - /// @brief Context Enum - /// @details Defines a list of PHM logging context to choose from - enum class EContext : uint8_t - { - factory = 0, - supervision = 1, - recovery = 2, - watchdog = 3 - - }; - - /// @brief Get Logger (Singleton) - /// @brief Calls the score::mw::log::Logger Singleton for the given logging context - /// @param f_context Logging context - /// @return PhmLogger reference for the given logging context - static PhmLogger& getLogger(const EContext f_context) noexcept(true); - - /// @brief Invoke score::mw::log::Logger::LogFatal() - Stream LogFatal() noexcept; - - /// @brief Invoke score::mw::log::Logger::LogError() - Stream LogError() noexcept; - - /// @brief Invoke score::mw::log::Logger::LogWarn() - Stream LogWarn() noexcept; - - /// @brief Invoke score::mw::log::Logger::LogInfo() - Stream LogInfo() noexcept; - - /// @brief Invoke score::mw::log::Logger::LogDebug() - Stream LogDebug() noexcept; - - /// @brief Invoke score::mw::log::Logger::LogVerbose() - Stream LogVerbose() noexcept; - -protected: - /// @brief Constructor - /// @param f_context Logging context ID (must match to logging configurations) - /// @param f_description Logging context description - PhmLogger(std::string_view f_context, std::string_view f_description) noexcept(true); - - /* RULECHECKER_comment(0, 5, check_incomplete_data_member_construction, "Default constructor is not provided\ - the member initializer", false) */ - /// @brief Default Move Constructor - PhmLogger(PhmLogger&&) = default; - - /// @brief No Move Assignment - PhmLogger& operator=(PhmLogger&&) = delete; - /// @brief No Copy Constructor - PhmLogger(const PhmLogger&) = delete; - /// @brief No Copy Assignment - PhmLogger& operator=(const PhmLogger&) = delete; - - /// @brief Default Destructor - virtual ~PhmLogger() = default; - -private: - /// @brief Logger reference for specific context - // Logger& logger_r; - Logger logger_r; -}; - -} // namespace logging -} // namespace saf -} // namespace lcm -} // namespace score - -#endif diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.cpp index ac4c48b45..022dfa8de 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.cpp @@ -16,6 +16,7 @@ #include #include +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include "score/mw/launch_manager/alive_monitor/details/common/Types.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" @@ -37,7 +38,6 @@ Alive::Alive(const AliveSupervisionCfg& f_aliveCfg_r) k_isMinCheckDisabled(f_aliveCfg_r.isMinCheckDisabled), k_isMaxCheckDisabled(f_aliveCfg_r.isMaxCheckDisabled), k_failedSupervisionCyclesTolerance(f_aliveCfg_r.failedCyclesTolerance), - logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::supervision)), recoveryClient_p(f_aliveCfg_r.recoveryClient), processIdentifier_(f_aliveCfg_r.processIdentifier), timeSortingUpdateEventBuffer(common::TimeSortingBuffer(f_aliveCfg_r.checkpointBufferSize)) @@ -342,8 +342,8 @@ bool Alive::setReferenceCycleTimestamps(timers::NanoSecondType f_baseValue) noex { if (f_baseValue > UINT64_MAX - k_aliveReferenceCycle) { - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") overflow appeared during increase of reference cycle timestamps"; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") overflow appeared during increase of reference cycle timestamps"; eventTimestamp = std::max(referenceCycleEnd + 1U, UINT64_MAX); switchToExpired(EReason::kOverflow); return true; @@ -357,8 +357,8 @@ void Alive::incIndicationCount(const timers::NanoSecondType f_updateEventTimesta { if (indicationCount == UINT32_MAX) { - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") overflow appeared during incrementation of indication count"; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") overflow appeared during incrementation of indication count"; eventTimestamp = f_updateEventTimestamp; return switchToExpired(EReason::kOverflow); } @@ -410,8 +410,8 @@ void Alive::evaluateRefCycleOutOfFailed(void) noexcept(true) { if (failedSupervisionCycles == UINT32_MAX) { - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") overflow appeared during incrementation of failed supervision cycles"; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") overflow appeared during incrementation of failed supervision cycles"; switchToExpired(EReason::kOverflow); return; } @@ -448,7 +448,7 @@ void Alive::switchToDeactivated(void) noexcept(true) referenceCycleStart = 0U; referenceCycleEnd = UINT64_MAX; - logger_r.LogDebug() << "Alive Supervision (" << getConfigName() << ") switched to DEACTIVATED."; + LM_LOG_DEBUG() << "Alive Supervision (" << getConfigName() << ") switched to DEACTIVATED."; pushResultToObservers(); } @@ -457,7 +457,7 @@ void Alive::switchToOk(void) noexcept(true) { aliveStatus = EStatus::kOk; failedSupervisionCycles = 0U; - logger_r.LogInfo() << "Alive Supervision (" << getConfigName() << ") switched to OK."; + LM_LOG_INFO() << "Alive Supervision (" << getConfigName() << ") switched to OK."; pushResultToObservers(); } @@ -483,17 +483,17 @@ void Alive::switchToExpired(Alive::EReason reason) noexcept(true) switch (dataLossReason) { case EDataLossReason::kSharedMemory: - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") switched to EXPIRED, due to shared memory overflow."; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") switched to EXPIRED, due to shared memory overflow."; break; case EDataLossReason::kBufferFull: - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") switched to EXPIRED, due to buffer overflow."; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") switched to EXPIRED, due to buffer overflow."; break; default: SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(dataLossReason != EDataLossReason::kNoDataLoss); - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") switched to EXPIRED, due to unknown data loss case."; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() + << ") switched to EXPIRED, due to unknown data loss case."; break; } break; @@ -504,12 +504,11 @@ void Alive::switchToExpired(Alive::EReason reason) noexcept(true) } case EReason::kOverflow: { - logger_r.LogError() << "Alive Supervision (" << getConfigName() - << ") switched to EXPIRED, due to overflow."; + LM_LOG_ERROR() << "Alive Supervision (" << getConfigName() << ") switched to EXPIRED, due to overflow."; break; } default: - logger_r.LogWarn() << "Alive Supervision (" << getConfigName() << ") switched to EXPIRED"; + LM_LOG_WARN() << "Alive Supervision (" << getConfigName() << ") switched to EXPIRED"; break; } @@ -522,13 +521,13 @@ void Alive::switchToExpired(Alive::EReason reason) noexcept(true) const bool enqueued = recoveryClient_p->sendRecoveryRequest(processIdentifier_); if (enqueued) { - logger_r.LogDebug() << "Recovery request enqueued successfully for alive supervision " << getConfigName() - << "failure"; + LM_LOG_DEBUG() << "Recovery request enqueued successfully for alive supervision " << getConfigName() + << "failure"; } else { - logger_r.LogError() << "Failed to enqueue recovery request for alive supervision" << getConfigName() - << "failure (ring buffer full)"; + LM_LOG_ERROR() << "Failed to enqueue recovery request for alive supervision" << getConfigName() + << "failure (ring buffer full)"; recoveryEnqueueFailed_ = true; } @@ -576,10 +575,10 @@ void Alive::logExpiredFailedStateDetails() const noexcept(true) * true_no_defect) */ const std::uint64_t aliveIndicationMargin{minError ? k_minAliveIndications : k_maxAliveIndications}; const std::string_view expectedComparison{minError ? ">=" : "<="}; - logger_r.LogWarn() << "Alive Supervision (" << getConfigName() << ")" << failedState << ", due to" - << indicationCount << "reported alive indication(s) (expected" << expectedComparison - << aliveIndicationMargin << "). Failed supervision cycles:" << failedSupervisionCycles << "/" - << k_failedSupervisionCyclesTolerance; + LM_LOG_WARN() << "Alive Supervision (" << getConfigName() << ")" << failedState << ", due to" << indicationCount + << "reported alive indication(s) (expected" << expectedComparison << aliveIndicationMargin + << "). Failed supervision cycles:" << failedSupervisionCycles << "/" + << k_failedSupervisionCyclesTolerance; } timers::NanoSecondType Alive::getTimestampOfUpdateEvent(const TimeSortedUpdateEvent f_updateEvent) noexcept(true) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.hpp index 61ca5b82d..6e745963b 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/Alive.hpp @@ -21,7 +21,6 @@ #include "score/mw/launch_manager/alive_monitor/details/common/TimeSortingBuffer.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifappl/Checkpoint.hpp" #include "score/mw/launch_manager/alive_monitor/details/ifexm/ProcessState.hpp" -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/ISupervision.hpp" #include "score/mw/launch_manager/alive_monitor/details/supervision/SupervisionCfg.hpp" #include "score/mw/launch_manager/alive_monitor/details/timers/Timers_OsClock.hpp" @@ -301,9 +300,6 @@ class Alive : public ISupervision, /// @brief Failed supervision cycle tolerance (debouncing of alive failure) const uint32_t k_failedSupervisionCyclesTolerance; - /// @brief Logger - logging::PhmLogger& logger_r; - /// @brief Recovery client invoked when supervision expires (null means recovery is disabled) std::shared_ptr recoveryClient_p; diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/BUILD index 626725bf1..d1419f637 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/supervision/BUILD @@ -50,8 +50,8 @@ cc_library( "//score/launch_manager/src/daemon/src/alive_monitor/details/common:time_sorting_buffer", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifappl:checkpoint", "//score/launch_manager/src/daemon/src/alive_monitor/details/ifexm:process_state", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:timers_os_clock", + "//score/launch_manager/src/daemon/src/common:log", "//score/launch_manager/src/daemon/src/recovery_client", "@score_baselibs//score/language/futurecpp", ], diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/timers/OsClockInterface.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/timers/OsClockInterface.hpp index af2dbbe3b..3d48ef864 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/timers/OsClockInterface.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/timers/OsClockInterface.hpp @@ -81,7 +81,6 @@ class OsClockInterface /// @brief Stop the measurement of the initialization process /// Prints out the time it took for initialization /// @param[in] f_osClock_r Clock abstraction - /// @param[in] f_logger_r The logger for logging the measured time long endMeasurement() { // In case getting the timestamp fails, the resulting measurement will be 0 @@ -92,7 +91,7 @@ class OsClockInterface const long nsDiff{initFinishedTime.tv_nsec - startTime.tv_nsec}; // coverity[autosar_cpp14_a4_7_1_violation] max long 2,147,483,647 ms which ~ 24.8 days which nobody will wait for const long ms{(secDiff * 1000 /*ms per sec*/) + (nsDiff / 1000000 /*ns per ms*/)}; - // f_logger_r.LogDebug() << "Phm Daemon: Initialization took " << ms << " ms"; + // LM_LOG_DEBUG() << "Phm Daemon: Initialization took " << ms << " ms"; return ms; } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/BUILD b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/BUILD index 7b52366f4..2686257f0 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/BUILD +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/BUILD @@ -59,8 +59,8 @@ cc_library( ":i_device_config_factory", ":i_watchdog_if", ":watchdog", - "//score/launch_manager/src/daemon/src/alive_monitor/details/logging:phm_logging", "//score/launch_manager/src/daemon/src/alive_monitor/details/timers:os_clock_interface", + "//score/launch_manager/src/daemon/src/common:log", "@score_baselibs//score/language/futurecpp", ], ) diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.cpp b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.cpp index 31beafc1d..1e8ee82cb 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.cpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ #include "score/mw/launch_manager/alive_monitor/details/watchdog/WatchdogImpl.hpp" +#include "score/launch_manager/src/daemon/src/common/log.hpp" #include #include @@ -54,13 +55,7 @@ T secToMs(const T f_timeout) /* RULECHECKER_comment(0:0,3:0, check_expensive_to_copy_in_parameter, "Move only types cannot be passed by const * ref",true_no_defect) */ /* RULECHECKER_comment(0:0,9:0, check_min_instructions, "Constructor with empty body is valid", true_no_defect) */ -WatchdogImpl::WatchdogImpl() noexcept - : IWatchdogIf(), - watchdogDevices(), - state(ELibState::idle), - logger_r(logging::PhmLogger::getLogger(logging::PhmLogger::EContext::watchdog)) -{ -} +WatchdogImpl::WatchdogImpl() noexcept : IWatchdogIf(), watchdogDevices(), state(ELibState::idle) {} bool WatchdogImpl::init(std::int64_t f_cycleTimeInNs, const IDeviceConfigFactory& f_configFactory) noexcept { @@ -70,7 +65,7 @@ bool WatchdogImpl::init(std::int64_t f_cycleTimeInNs, const IDeviceConfigFactory const auto configurations{f_configFactory.getDeviceConfigurations()}; if (!configurations) { - logger_r.LogError() << "Watchdog: Invalid watchdog device configuration. Watchdog initialization failed."; + LM_LOG_ERROR() << "Watchdog: Invalid watchdog device configuration. Watchdog initialization failed."; isSuccess = false; } @@ -82,8 +77,8 @@ bool WatchdogImpl::init(std::int64_t f_cycleTimeInNs, const IDeviceConfigFactory { if (!configureDevice(config, f_cycleTimeInNs)) { - logger_r.LogError() << "Watchdog: Error when configuring watchdog device" << config.fileName - << "- Watchdog initialization failed."; + LM_LOG_ERROR() << "Watchdog: Error when configuring watchdog device" << config.fileName + << "- Watchdog initialization failed."; isSuccess = false; } } @@ -93,7 +88,7 @@ bool WatchdogImpl::init(std::int64_t f_cycleTimeInNs, const IDeviceConfigFactory { isSuccess = false; watchdogDevices.clear(); - logger_r.LogError() << "Watchdog: Watchdog initialization failed:" << e.what(); + LM_LOG_ERROR() << "Watchdog: Watchdog initialization failed:" << e.what(); } return isSuccess; } @@ -193,7 +188,7 @@ void WatchdogImpl::fireWatchdogReaction() noexcept if (watchdogDevice.fileDescriptor >= 0) { // This log message is introduced as a result of FMEA - logger_r.LogFatal() << "Watchdog: Trigger RESET for watchdog" << watchdogDevice.config.fileName; + LM_LOG_FATAL() << "Watchdog: Trigger RESET for watchdog" << watchdogDevice.config.fileName; std::uint16_t timeout{0U}; // Save to ignore return value here. If setting timeout does not work, watchdog will eventually fire @@ -292,8 +287,8 @@ bool WatchdogImpl::setTimeout(std::int32_t f_fd, std::uint16_t f_timeoutInMs) co const bool isSuccessful{(result >= 0) && (timeoutBefore == timeout)}; if (!isSuccessful) { - logger_r.LogDebug() << "Watchdog: Setting watchdog timeout value failed. Wanted timeout:" << timeoutBefore - << "ms, returned timeout:" << timeout << "ms, ioctl result:" << result; + LM_LOG_DEBUG() << "Watchdog: Setting watchdog timeout value failed. Wanted timeout:" << timeoutBefore + << "ms, returned timeout:" << timeout << "ms, ioctl result:" << result; } return isSuccessful; } @@ -312,12 +307,12 @@ bool WatchdogImpl::enableDevice(WatchdogDevice& f_state_r) const noexcept if (result >= 0) { - logger_r.LogInfo() << "Watchdog: Current watchdog (" << f_state_r.config.fileName << ") timeout is" - << configuredTimeout << "ms"; + LM_LOG_INFO() << "Watchdog: Current watchdog (" << f_state_r.config.fileName << ") timeout is" + << configuredTimeout << "ms"; } else { - logger_r.LogError() << "Watchdog: Getting watchdog (" << f_state_r.config.fileName << ") timeout failed."; + LM_LOG_ERROR() << "Watchdog: Getting watchdog (" << f_state_r.config.fileName << ") timeout failed."; isSuccess = false; } @@ -330,8 +325,8 @@ bool WatchdogImpl::enableDevice(WatchdogDevice& f_state_r) const noexcept { if (!setEnableCardOption(f_state_r.fileDescriptor)) { - logger_r.LogError() << "Watchdog: Enabling watchdog (" << f_state_r.config.fileName - << ") with option WDIOS_ENABLECARD failed."; + LM_LOG_ERROR() << "Watchdog: Enabling watchdog (" << f_state_r.config.fileName + << ") with option WDIOS_ENABLECARD failed."; isSuccess = false; } } @@ -355,20 +350,20 @@ bool WatchdogImpl::updateTimeout(WatchdogDevice& f_state_r, std::int32_t f_confi result = getRemainingTime(remainingTime, f_state_r.fileDescriptor); if (result >= 0) { - logger_r.LogInfo() << "Watchdog: Remaining time for watchdog (" << f_state_r.config.fileName << ") is" - << remainingTime << "ms"; + LM_LOG_INFO() << "Watchdog: Remaining time for watchdog (" << f_state_r.config.fileName << ") is" + << remainingTime << "ms"; } else { - logger_r.LogError() << "Watchdog: Getting remaining time for watchdog (" << f_state_r.config.fileName - << ") failed."; + LM_LOG_ERROR() << "Watchdog: Getting remaining time for watchdog (" << f_state_r.config.fileName + << ") failed."; isSuccess = false; } } else { - logger_r.LogInfo() << "Watchdog: Provided and current watchdog (" << f_state_r.config.fileName - << ") timeouts are same."; + LM_LOG_INFO() << "Watchdog: Provided and current watchdog (" << f_state_r.config.fileName + << ") timeouts are same."; isSetTimeout = false; } @@ -376,12 +371,12 @@ bool WatchdogImpl::updateTimeout(WatchdogDevice& f_state_r, std::int32_t f_confi { if (setTimeout(f_state_r.fileDescriptor, f_state_r.config.timeoutMax)) { - logger_r.LogInfo() << "Watchdog: Watchdog (" << f_state_r.config.fileName - << ") is configured with timeout =" << f_state_r.config.timeoutMax << "ms"; + LM_LOG_INFO() << "Watchdog: Watchdog (" << f_state_r.config.fileName + << ") is configured with timeout =" << f_state_r.config.timeoutMax << "ms"; } else { - logger_r.LogError() << "Watchdog: Setting watchdog (" << f_state_r.config.fileName << ") timeout failed."; + LM_LOG_ERROR() << "Watchdog: Setting watchdog (" << f_state_r.config.fileName << ") timeout failed."; isSuccess = false; } } @@ -444,16 +439,16 @@ bool WatchdogImpl::isValidDeviceConfig(const DeviceConfig& f_config_r, std::int6 if (!hasValidTimeout(f_config_r)) { - logger_r.LogError() << "Watchdog: Invalid timeout configuration of [" << f_config_r.timeoutMin << "," - << f_config_r.timeoutMax << "]. Valid interval range is [" << kTimeoutMinMillis << "," - << kTimeoutMaxMillis << "]"; + LM_LOG_ERROR() << "Watchdog: Invalid timeout configuration of [" << f_config_r.timeoutMin << "," + << f_config_r.timeoutMax << "]. Valid interval range is [" << kTimeoutMinMillis << "," + << kTimeoutMaxMillis << "]"; return false; } if (!validateTimeoutWithCycleTime(f_cycleTimeInNs, f_config_r)) { - logger_r.LogError() << "Watchdog: The watchdog device" << f_config_r.fileName - << "cannot be triggered in time with a configured cycle time of" << f_cycleTimeInNs << "ns"; + LM_LOG_ERROR() << "Watchdog: The watchdog device" << f_config_r.fileName + << "cannot be triggered in time with a configured cycle time of" << f_cycleTimeInNs << "ns"; return false; } diff --git a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.hpp b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.hpp index 1e2ae2215..5b64bd3ed 100644 --- a/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.hpp +++ b/score/launch_manager/src/daemon/src/alive_monitor/details/watchdog/WatchdogImpl.hpp @@ -17,7 +17,6 @@ #include #include -#include "score/mw/launch_manager/alive_monitor/details/logging/PhmLogger.hpp" #include "score/mw/launch_manager/alive_monitor/details/watchdog/IDeviceConfigFactory.hpp" #include "score/mw/launch_manager/alive_monitor/details/watchdog/IWatchdogIf.hpp" #include @@ -192,8 +191,6 @@ class WatchdogImpl : public IWatchdogIf std::vector watchdogDevices; /// @brief The internal state of this class ELibState state; - /// @brief Logging - logging::PhmLogger& logger_r; }; } // namespace watchdog diff --git a/score/launch_manager/src/daemon/src/process_group_manager/alive_monitor_thread.hpp b/score/launch_manager/src/daemon/src/process_group_manager/alive_monitor_thread.hpp index 807abc54a..5624bf50d 100644 --- a/score/launch_manager/src/daemon/src/process_group_manager/alive_monitor_thread.hpp +++ b/score/launch_manager/src/daemon/src/process_group_manager/alive_monitor_thread.hpp @@ -15,6 +15,7 @@ #include "score/mw/launch_manager/alive_monitor/details/daemon/IAliveMonitor.hpp" #include +#include #include #include "score/mw/launch_manager/process_group_manager/ialive_monitor_thread.hpp"