From 7498a767929c458efe465d59c1e02cdad1cefaba Mon Sep 17 00:00:00 2001 From: Arifulla Shariff <166038015+ashariff-11@users.noreply.github.com> Date: Tue, 8 Oct 2024 09:47:13 +0200 Subject: [PATCH] logging.h NB wrapper files added --- .../src/modules/module_logging_config.cpp | 63 +++++++++++++ .../src/modules/module_logging_config.h | 46 ++++++++++ .../src/wrappers/wrapper_logging_config.cpp | 32 +++++++ .../src/wrappers/wrapper_logging_config.h | 89 +++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 lang/python/nanobind_core/src/modules/module_logging_config.cpp create mode 100644 lang/python/nanobind_core/src/modules/module_logging_config.h create mode 100644 lang/python/nanobind_core/src/wrappers/wrapper_logging_config.cpp create mode 100644 lang/python/nanobind_core/src/wrappers/wrapper_logging_config.h diff --git a/lang/python/nanobind_core/src/modules/module_logging_config.cpp b/lang/python/nanobind_core/src/modules/module_logging_config.cpp new file mode 100644 index 0000000000..997b2f37aa --- /dev/null +++ b/lang/python/nanobind_core/src/modules/module_logging_config.cpp @@ -0,0 +1,63 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @brief Add Publisher config structs to nanobind module +**/ + + +#include +#include + +void AddLoggingConfigStructToModule(const nanobind::module_& module) +{ + // Bind the Console::Configuration structure + nanobind::class_(m, "ConsoleConfiguration") + .def(nanobind::init<>()) // Constructor binding + .def_rw("enable", &eCAL::Logging::Sinks::Console::CNBConsoleConfiguration::enable) + .def_rw("filter_log_con", &eCAL::Logging::Sinks::Console::CNBConsoleConfiguration::filter_log_con); + + // Bind the File::Configuration structure + nanobind::class_(m, "FileConfiguration") + .def(nanobind::init<>()) // Constructor binding + .def_rw("enable", &eCAL::Logging::Sinks::File::CNBFileConfiguration::enable) + .def_rw("path", &eCAL::Logging::Sinks::File::CNBFileConfiguration::path) + .def_rw("filter_log_file", &eCAL::Logging::Sinks::File::CNBFileConfiguration::filter_log_file); + + // Bind the UDP::Configuration structure + nanobind::class_(m, "UDPConfiguration") + .def(nanobind::init<>()) // Constructor binding + .def_rw("enable", &eCAL::Logging::Sinks::UDP::CNBUDPConfiguration::enable) + .def_rw("port", &eCAL::Logging::Sinks::UDP::CNBUDPConfiguration::port) + .def_rw("filter_log_udp", &eCAL::Logging::Sinks::UDP::CNBUDPConfiguration::filter_log_udp); + + // Bind the Sinks::Configuration structure + nanobind::class_(m, "SinksConfiguration") + .def(nanobind::init<>()) // Constructor binding + .def_rw("console", &eCAL::Logging::Sinks::NBSinksConfiguration::console) + .def_rw("file", &eCAL::Logging::Sinks::NBSinksConfiguration::file) + .def_rw("udp", &eCAL::Logging::Sinks::NBSinksConfiguration::udp); + + // Bind the Logging::Configuration structure + nanobind::class_(m, "LoggingConfiguration") + .def(nanobind::init<>()) // Constructor binding + .def_rw("sinks", &eCAL::Logging::CNBLoggingConfiguration::sinks); + +} + diff --git a/lang/python/nanobind_core/src/modules/module_logging_config.h b/lang/python/nanobind_core/src/modules/module_logging_config.h new file mode 100644 index 0000000000..998a2cc2fa --- /dev/null +++ b/lang/python/nanobind_core/src/modules/module_logging_config.h @@ -0,0 +1,46 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @file module_datatypeinfo.h + * @brief Nanobind module for structs of file config/logging.h +**/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief Function to Add Nanobind module + * + * @param module The nanobind module variable +**/ +void AddLoggingConfigStructToModule(const nanobind::module_& module); diff --git a/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.cpp b/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.cpp new file mode 100644 index 0000000000..edfdf7a47a --- /dev/null +++ b/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.cpp @@ -0,0 +1,32 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @brief logging.h configuration, adapted for Nanobind +**/ + +#include + +namespace eCAL +{ + //Logging::Sinks::CNBLoggingConfiguration::CNBLoggingConfiguration() + //{ + // Logging::Sinks::Configuration::Configuration(); + //} +} diff --git a/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.h b/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.h new file mode 100644 index 0000000000..b160312437 --- /dev/null +++ b/lang/python/nanobind_core/src/wrappers/wrapper_logging_config.h @@ -0,0 +1,89 @@ +/* ========================= eCAL LICENSE ================================= + * + * Copyright (C) 2016 - 2024 Continental Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ========================= eCAL LICENSE ================================= +*/ + +/** + * @file wrapper_publisher_config.h + * @brief Nanobind wrapper for structs of Publisher config +**/ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace eCAL +{ + namespace Logging + { + namespace Sinks + { + namespace Console + { + struct CNBConsoleConfiguration + { + bool enable{ true }; //!< Enable console logging (Default: true) + eCAL_Logging_Filter filter_log_con{ log_level_error | log_level_fatal }; /*!< Log messages logged to console (all, info, warning, error, fatal, debug1, debug2, debug3, debug4) + (Default: info, warning, error, fatal)*/ + }; + } + + namespace File + { + struct CNBFileConfiguration + { + bool enable{ false }; //!< Enable file logging (Default: false) + std::string path{ "" }; //!< Path to log file (Default: "") + eCAL_Logging_Filter filter_log_file{ log_level_none }; /*!< Log messages logged into file system (all, info, warning, error, fatal, debug1, debug2, debug3, debug4) + (Default: info, warning, error, fatal)*/ + }; + } + + namespace UDP + { + struct CNBUDPConfiguration + { + bool enable{ true }; //!< Enable UDP logging (Default: false) + unsigned int port{ 14001 }; //!< UDP port number (Default: 14001) + eCAL_Logging_Filter filter_log_udp{ log_level_default }; //!< Log messages logged via udp network (Default: info, warning, error, fatal) + }; + } + + struct CNBSinksConfiguration + { + // CNBLoggingConfiguration(); + + Console::CNBConsoleConfiguration console; + File::CNBFileConfiguration file; + UDP::CNBUDPConfiguration udp; + }; + } + + struct CNBLoggingConfiguration + { + Sinks::Configuration sinks; + }; + } +}