From 84a8e1690d7083e36db3e3bedbf8567d63828152 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 31 Oct 2017 12:21:59 +0100 Subject: [PATCH] Fix logging facility. Liblinphone outputs in the "liblinphone" log domain, mediastreamer and ortp have now their own log domains too. --- coreapi/CMakeLists.txt | 1 + coreapi/linphonecore.c | 7 +++++-- coreapi/logging.c | 2 +- tester/liblinphone_tester.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 85e13205c..d1190e83a 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -142,6 +142,7 @@ bc_git_version(liblinphone ${PROJECT_VERSION}) add_definitions( -DUSE_BELLESIP -DLIBLINPHONE_EXPORTS + -DBCTBX_LOG_DOMAIN="liblinphone" ) set(LIBS diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 441cc70e8..8d40a9ddc 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -506,14 +506,17 @@ void linphone_core_set_log_level(OrtpLogLevel loglevel) { linphone_logging_service_set_log_level(log_service, _bctbx_log_level_to_linphone_log_level(loglevel)); } + void linphone_core_set_log_level_mask(unsigned int mask) { LinphoneLoggingService *log_service = linphone_logging_service_get(); linphone_logging_service_set_log_level_mask(log_service, _bctbx_log_mask_to_linphone_log_mask(mask)); } + unsigned int linphone_core_get_log_level_mask(void) { LinphoneLoggingService *log_service = linphone_logging_service_get(); return linphone_logging_service_get_log_level_mask(log_service); } + static int _open_log_collection_file_with_idx(int idx) { struct stat statbuf; char *log_filename; @@ -616,8 +619,8 @@ static void linphone_core_log_collection_handler(const char *domain, OrtpLogLeve } if (liblinphone_log_collection_file) { ortp_mutex_lock(&liblinphone_log_collection_mutex); - ret = fprintf(liblinphone_log_collection_file,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i %s %s\n", - 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, (int)(tp.tv_usec / 1000), lname, msg); + ret = fprintf(liblinphone_log_collection_file,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i [%s] %s %s\n", + 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, (int)(tp.tv_usec / 1000), domain, lname, msg); fflush(liblinphone_log_collection_file); if (ret > 0) { liblinphone_log_collection_file_size += (size_t)ret; diff --git a/coreapi/logging.c b/coreapi/logging.c index 5af54e5d5..7c7960650 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -202,7 +202,7 @@ void linphone_logging_service_set_log_level_mask(LinphoneLoggingService *log_ser } unsigned int linphone_logging_service_get_log_level_mask(const LinphoneLoggingService *log_service) { - return _bctbx_log_mask_to_linphone_log_mask(bctbx_get_log_level_mask(ORTP_LOG_DOMAIN)); + return _bctbx_log_mask_to_linphone_log_mask(bctbx_get_log_level_mask(BCTBX_LOG_DOMAIN)); } void linphone_logging_service_set_log_file(const LinphoneLoggingService *service, const char *dir, const char *filename, size_t max_size) { diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 2557f8de0..da5f813ae 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -148,7 +148,7 @@ static void log_handler(int lev, const char *fmt, va_list args) { #endif va_end(cap); #endif - bctbx_logv(ORTP_LOG_DOMAIN, lev, fmt, args); + bctbx_logv(BCTBX_LOG_DOMAIN, lev, fmt, args); } void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) {