diff --git a/lang/python/nanobind_core/src/core/config/py_configuration.cpp b/lang/python/nanobind_core/src/core/config/py_configuration.cpp index 5346a4696c..ba7eaeba0a 100644 --- a/lang/python/nanobind_core/src/core/config/py_configuration.cpp +++ b/lang/python/nanobind_core/src/core/config/py_configuration.cpp @@ -27,6 +27,9 @@ #include #include +// Nanobind includes to map stl types to python types +#include + namespace nb = nanobind; void AddConfigConfiguration(nanobind::module_& module) diff --git a/lang/python/nanobind_core/src/core/pubsub/py_publisher.cpp b/lang/python/nanobind_core/src/core/pubsub/py_publisher.cpp index e720ea6687..7c5aa7dbf3 100644 --- a/lang/python/nanobind_core/src/core/pubsub/py_publisher.cpp +++ b/lang/python/nanobind_core/src/core/pubsub/py_publisher.cpp @@ -20,6 +20,10 @@ #include #include +// Nanobind includes to map stl types to python types +#include +#include + namespace nb = nanobind; using namespace eCAL; diff --git a/lang/python/nanobind_core/src/core/pubsub/py_subscriber.cpp b/lang/python/nanobind_core/src/core/pubsub/py_subscriber.cpp index 8fb60d81a0..1330359a5b 100644 --- a/lang/python/nanobind_core/src/core/pubsub/py_subscriber.cpp +++ b/lang/python/nanobind_core/src/core/pubsub/py_subscriber.cpp @@ -28,6 +28,7 @@ #include #include +#include #include diff --git a/lang/python/nanobind_core/src/core/types/py_custom_data_types.cpp b/lang/python/nanobind_core/src/core/types/py_custom_data_types.cpp index 7e1ec20348..ebc06bc7e5 100644 --- a/lang/python/nanobind_core/src/core/types/py_custom_data_types.cpp +++ b/lang/python/nanobind_core/src/core/types/py_custom_data_types.cpp @@ -20,6 +20,8 @@ #include #include +#include + namespace nb = nanobind; using namespace eCAL; diff --git a/lang/python/nanobind_core/src/core/types/py_logging.cpp b/lang/python/nanobind_core/src/core/types/py_logging.cpp index b0291dd4dc..d94d5bd695 100644 --- a/lang/python/nanobind_core/src/core/types/py_logging.cpp +++ b/lang/python/nanobind_core/src/core/types/py_logging.cpp @@ -26,6 +26,7 @@ #include #include +#include namespace nb = nanobind; using namespace eCAL::Logging; diff --git a/lang/python/nanobind_core/src/nanobind_core.cpp b/lang/python/nanobind_core/src/nanobind_core.cpp index d7354ac2a9..aaeba45f7a 100644 --- a/lang/python/nanobind_core/src/nanobind_core.cpp +++ b/lang/python/nanobind_core/src/nanobind_core.cpp @@ -67,30 +67,34 @@ #include #include +namespace nb = nanobind; -NB_MODULE(nanobind_core, m) { - AddConfig(m); - AddCore(m); - AddInit(m); - AddLog(m); - AddLogLevel(m); +NB_MODULE(nanobind_core, core) { + auto init = core.def_submodule("init", "Initialization related functions and classes"); - AddTypes(m); + AddCore(core); - AddConfigApplication(m); - AddConfigConfiguration(m); - AddConfigLogging(m); - AddConfigPublisher(m); - AddConfigRegistration(m); - AddConfigSubscriber(m); - AddConfigTime(m); - AddConfigTransportLayer(m); + AddInit(init); + AddLog(core); + AddLogLevel(core); - AddPubsubPublisher(m); - AddPubsubSubscriber(m); - AddPubsubTypes(m); + AddTypes(core); + AddConfigApplication(core); + AddConfigLogging(core); + AddConfigPublisher(core); + AddConfigRegistration(core); + AddConfigSubscriber(core); + AddConfigTime(core); + AddConfigTransportLayer(core); + AddConfigConfiguration(core); // need to add last, so the others are available. + AddConfig(core); - AddTypesCustomDataTypes(m); - AddTypesLogging(m); + AddPubsubPublisher(core); + AddPubsubSubscriber(core); + AddPubsubTypes(core); + + + AddTypesCustomDataTypes(core); + AddTypesLogging(core); } diff --git a/lang/python/samples/CMakeLists.txt b/lang/python/samples/CMakeLists.txt index ef7dcba48b..8cc757bb0f 100644 --- a/lang/python/samples/CMakeLists.txt +++ b/lang/python/samples/CMakeLists.txt @@ -29,6 +29,7 @@ set(python_samples_nanobind_core nanobind_core/pubsub/nb_binary_snd.py nanobind_core/service/nb_minimal_service_client.py nanobind_core/service/nb_minimal_service_server.py + nanobind_core/nb_logging.py ) function(add_sample_to_solution python_filenname) diff --git a/lang/python/samples/nanobind_core/nb_logging.py b/lang/python/samples/nanobind_core/nb_logging.py new file mode 100644 index 0000000000..4ebb61c781 --- /dev/null +++ b/lang/python/samples/nanobind_core/nb_logging.py @@ -0,0 +1,43 @@ +# ========================= eCAL LICENSE ================================= +# +# Copyright (C) 2016 - 2025 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 ================================= +import ecal.nanobind_core as ecal_core +help(ecal_core) + +def main(): + + # For pure logging, it's not necessary to modify the configuration. + # However, in order to also receive logging information it's necessary to be turned on + config = ecal_core.init.get_configuration() + config.logging.receiver.enable = True + ecal_core.initialize(config, 'logging', ecal_core.init.ALL) + + ecal_core.log(ecal_core.LogLevel.INFO, "Hello Hello") + ecal_core.log(ecal_core.LogLevel.WARNING, "Help") + + + all_logging = ecal_core.get_logging() + + for log in all_logging.log_messages: + print(log) + + ecal_core.finalize() + + + +if __name__ == "__main__": + main()