diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 952becdee..bcc15a96e 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -128,6 +128,7 @@ endif() set(LINPHONE_SOURCE_FILES_OBJC) if (IOS) list(APPEND LINPHONE_SOURCE_FILES_OBJC ringtoneplayer_ios.m ringtoneplayer_ios.h) + list(APPEND LINPHONE_SOURCE_FILES_CXX linphonecore_ios.cc) endif() diff --git a/coreapi/linphonecore_ios.cc b/coreapi/linphonecore_ios.cc new file mode 100644 index 000000000..adac71cb5 --- /dev/null +++ b/coreapi/linphonecore_ios.cc @@ -0,0 +1,44 @@ +#include +#include "linphone/core.h" + +#ifdef __APPLE__ +#include "TargetConditionals.h" +#endif + +#if TARGET_OS_IPHONE +static void linphone_iphone_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) { + char* str = bctbx_strdup_vprintf(fmt, args); + const char *levname = "undef"; + + if (!domain) + domain = "lib"; + + switch (lev) { + case ORTP_FATAL: + levname = "Fatal"; + break; + case ORTP_ERROR: + levname = "Error"; + break; + case ORTP_WARNING: + levname = "Warning"; + break; + case ORTP_MESSAGE: + levname = "Message"; + break; + case ORTP_DEBUG: + levname = "Debug"; + break; + case ORTP_TRACE: + levname = "Trace"; + break; + case ORTP_LOGLEV_END: + return; + } + fprintf(stdout,"[%s] %s", levname, str); +} + +extern "C" void linphone_iphone_enable_logs() { + linphone_core_enable_logs_with_cb(linphone_iphone_log_handler); +} +#endif \ No newline at end of file