Commit 9bf21045 authored by Ghislain MARY's avatar Ghislain MARY

Change API to set log handler and log level.

- Deprecate linphone_core_enable_logs(),
  linphone_core_enable_logs_with_cb() and linphone_core_disable_logs() functions.
- Introduce linphone_core_set_log_handler(), linphone_core_set_log_file() and linphone_core_set_log_level() functions.
parent bf2d6d78
......@@ -407,10 +407,29 @@ const LinphoneAddress *linphone_core_get_current_call_remote_address(struct _Lin
return linphone_call_get_remote_address(call);
}
void linphone_core_set_log_handler(OrtpLogFunc logfunc) {
ortp_set_log_handler(logfunc);
}
void linphone_core_set_log_file(FILE *file) {
if (file == NULL) file = stdout;
ortp_set_log_file(file);
}
void linphone_core_set_log_level(OrtpLogLevel loglevel) {
ortp_set_log_level_mask(loglevel);
if (loglevel == 0) {
sal_disable_logs();
} else {
sal_enable_logs();
}
}
/**
* Enable logs in supplied FILE*.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead.
*
* @param file a C FILE* where to fprintf logs. If null stdout is used.
*
......@@ -425,6 +444,7 @@ void linphone_core_enable_logs(FILE *file){
* Enable logs through the user's supplied log callback.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead.
*
* @param logfunc The address of a OrtpLogFunc callback whose protoype is
* typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
......@@ -439,6 +459,7 @@ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){
* Entirely disable logging.
*
* @ingroup misc
* @deprecated Use #linphone_core_set_log_level instead.
**/
void linphone_core_disable_logs(){
ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL);
......@@ -1197,6 +1218,7 @@ static void misc_config_read (LinphoneCore *lc) {
LpConfig *config=lc->config;
lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",15);
lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
linphone_core_set_log_level((OrtpLogLevel)lp_config_get_int(config,"misc","log_level",0));
}
......@@ -2152,9 +2174,13 @@ void linphone_core_iterate(LinphoneCore *lc){
lc->initial_subscribes_sent=TRUE;
}
if (one_second_elapsed && lp_config_needs_commit(lc->config)){
lp_config_sync(lc->config);
}
if (one_second_elapsed) {
if (ortp_get_log_level_mask() != lp_config_get_int(lc->config, "misc", "log_level", 0)) {
lp_config_set_int(lc->config, "misc", "log_level", ortp_get_log_level_mask());
}
if (lp_config_needs_commit(lc->config)) {
lp_config_sync(lc->config);
}
}
/**
......
......@@ -874,6 +874,35 @@ typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *contex
/* THE main API */
/**
* Define a log handler.
*
* @ingroup misc
*
* @param logfunc The function pointer of the log handler.
*/
void linphone_core_set_log_handler(OrtpLogFunc logfunc);
/**
* Define a log file.
*
* @ingroup misc
*
* If the file pointer passed as an argument is NULL, stdout is used instead.
*
* @param file A pointer to the FILE structure of the file to write to.
*/
void linphone_core_set_log_file(FILE *file);
/**
* Define the log level.
*
* @ingroup misc
*
* The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
* messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
*
* @param loglevel A bitmask of the log levels to set.
*/
void linphone_core_set_log_level(OrtpLogLevel loglevel);
void linphone_core_enable_logs(FILE *file);
void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
void linphone_core_disable_logs(void);
......
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