From 78e1f7f4d958ab835ac853f245cc6dfd44a02cd0 Mon Sep 17 00:00:00 2001 From: Patrick van Bennekom Date: Mon, 21 Aug 2023 08:32:05 +0000 Subject: [PATCH] Make it possible to use own logger instead of everest logger. Signed-off-by: Maaike Zijderveld, Alfen --- include/ocpp/common/charging_station_base.hpp | 2 ++ lib/CMakeLists.txt | 29 ++++++++++++++++++- lib/ocpp/common/charging_station_base.cpp | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/ocpp/common/charging_station_base.hpp b/include/ocpp/common/charging_station_base.hpp index 062009e04..7bb4340b0 100644 --- a/include/ocpp/common/charging_station_base.hpp +++ b/include/ocpp/common/charging_station_base.hpp @@ -7,6 +7,8 @@ #include #include +#include + namespace ocpp { /// \brief Common base class for OCPP1.6 and OCPP2.0.1 charging stations diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index bbe37978d..588bd2a36 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -47,9 +47,36 @@ target_include_directories(ocpp $ ) +############# +# Logging configuration +############# +if (EVEREST_CUSTOM_LOGGING_INCLUDE_PATH) + if (NOT EXISTS "${EVEREST_CUSTOM_LOGGING_INCLUDE_PATH}/everest/logging.hpp") + message(FATAL_ERROR "everest/logging.hpp not found in directory ${EVEREST_CUSTOM_LOGGING_INCLUDE_PATH}") + else() + target_include_directories(ocpp + PUBLIC + include + ${EVEREST_CUSTOM_LOGGING_INCLUDE_PATH} + ) + endif() + message(STATUS "Using the following logging header: ${EVEREST_CUSTOM_LOGGING_INCLUDE_PATH}/everest/logging.hpp") +endif() + +if (NOT EVEREST_CUSTOM_LOGGING_INCLUDE_PATH) + target_link_libraries(ocpp + PUBLIC + everest::log + ) + message(STATUS "Using the default logging header") +endif() + +############# +# End logging configuration +############# + target_link_libraries(ocpp PUBLIC - everest::log everest::timer websocketpp::websocketpp nlohmann_json_schema_validator diff --git a/lib/ocpp/common/charging_station_base.cpp b/lib/ocpp/common/charging_station_base.cpp index 6d1da8918..f7f4ef177 100644 --- a/lib/ocpp/common/charging_station_base.cpp +++ b/lib/ocpp/common/charging_station_base.cpp @@ -2,6 +2,7 @@ // Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest #include +#include namespace ocpp { ChargingStationBase::ChargingStationBase() : uuid_generator(boost::uuids::random_generator()) {