eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
854 stars 352 forks source link

Is there a corresponding log c++API provided for cyclonedds cxx #2015

Open usstmiracle opened 4 months ago

usstmiracle commented 4 months ago

As for cyclonedds-cxx Is there a similar log API and how should it be used? Is there an example of how to use the C++version log



struct dds_log_data {
  uint32_t priority;
  const char *file;
  uint32_t line;
  const char *function;
  const char *message;
};

typedef struct dds_log_data dds_log_data_t;

dds_return_t dds_set_log_sink(dds_log_write_fn_t *, const void *);
dds_return_t dds_set_trace_sink(dds_log_write_fn_t *, const void *);```
eboasson commented 4 months ago

Hi @usstmiracle, there is no such API for C++. It is also not really part of the Cyclone Application Programming Interface, but we did decide to make it publicly visible because it can come in really handy sometimes.

You should be able to do #include "dds/ddsrt/log.h" from C++ (the extern "C" bits are in place) and then you can use it just fine directly from C++.