Commit 583002cf authored by Simon Morlat's avatar Simon Morlat
Browse files

Fix logging facility. Liblinphone outputs in the "liblinphone" log domain,...

Fix logging facility. Liblinphone outputs in the "liblinphone" log domain, mediastreamer and ortp have now their own log domains too.
parent 3a8fb2bb
...@@ -153,6 +153,7 @@ bc_git_version(liblinphone ${PROJECT_VERSION}) ...@@ -153,6 +153,7 @@ bc_git_version(liblinphone ${PROJECT_VERSION})
add_definitions( add_definitions(
-DUSE_BELLESIP -DUSE_BELLESIP
-DLIBLINPHONE_EXPORTS -DLIBLINPHONE_EXPORTS
-DBCTBX_LOG_DOMAIN="liblinphone"
) )
set(LIBS set(LIBS
......
...@@ -481,14 +481,17 @@ void linphone_core_set_log_level(OrtpLogLevel loglevel) { ...@@ -481,14 +481,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)); 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) { void linphone_core_set_log_level_mask(unsigned int mask) {
LinphoneLoggingService *log_service = linphone_logging_service_get(); LinphoneLoggingService *log_service = linphone_logging_service_get();
linphone_logging_service_set_log_level_mask(log_service, _bctbx_log_mask_to_linphone_log_mask(mask)); 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) { unsigned int linphone_core_get_log_level_mask(void) {
LinphoneLoggingService *log_service = linphone_logging_service_get(); LinphoneLoggingService *log_service = linphone_logging_service_get();
return linphone_logging_service_get_log_level_mask(log_service); return linphone_logging_service_get_log_level_mask(log_service);
} }
static int _open_log_collection_file_with_idx(int idx) { static int _open_log_collection_file_with_idx(int idx) {
struct stat statbuf; struct stat statbuf;
char *log_filename; char *log_filename;
...@@ -591,8 +594,8 @@ static void linphone_core_log_collection_handler(const char *domain, OrtpLogLeve ...@@ -591,8 +594,8 @@ static void linphone_core_log_collection_handler(const char *domain, OrtpLogLeve
} }
if (liblinphone_log_collection_file) { if (liblinphone_log_collection_file) {
ortp_mutex_lock(&liblinphone_log_collection_mutex); ortp_mutex_lock(&liblinphone_log_collection_mutex);
ret = fprintf(liblinphone_log_collection_file,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i %s %s\n", 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), lname, msg); 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); fflush(liblinphone_log_collection_file);
if (ret > 0) { if (ret > 0) {
liblinphone_log_collection_file_size += ret; liblinphone_log_collection_file_size += ret;
......
...@@ -69,7 +69,7 @@ LinphoneLogLevel _bctbx_log_level_to_linphone_log_level(BctbxLogLevel level) { ...@@ -69,7 +69,7 @@ LinphoneLogLevel _bctbx_log_level_to_linphone_log_level(BctbxLogLevel level) {
if (response != tmap.cend()) { if (response != tmap.cend()) {
return response->first; return response->first;
} else { } else {
ms_fatal("%s(): invalid argument [%d]", __FUNCTION__, level); ms_fatal("%s(): invalid argument [%d]", __FUNCTION__, level);
return LinphoneLogLevelDebug; return LinphoneLogLevelDebug;
} }
} }
...@@ -175,9 +175,12 @@ LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const Linphone ...@@ -175,9 +175,12 @@ LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const Linphone
} }
static const char *_linphone_logging_service_log_domains[] = { static const char *_linphone_logging_service_log_domains[] = {
ORTP_LOG_DOMAIN, "bctbx",
"ortp",
"bzrtp", "bzrtp",
"mediastreamer",
BELLE_SIP_LOG_DOMAIN, BELLE_SIP_LOG_DOMAIN,
BCTBX_LOG_DOMAIN,
NULL NULL
}; };
...@@ -196,7 +199,7 @@ void linphone_logging_service_set_log_level_mask(LinphoneLoggingService *log_ser ...@@ -196,7 +199,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) { 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) { void linphone_logging_service_set_log_file(const LinphoneLoggingService *service, const char *dir, const char *filename, size_t max_size) {
......
...@@ -167,7 +167,7 @@ static void log_handler(int lev, const char *fmt, va_list args) { ...@@ -167,7 +167,7 @@ static void log_handler(int lev, const char *fmt, va_list args) {
#endif #endif
va_end(cap); va_end(cap);
#endif #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)) { void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment