Exemplo n.º 1
0
void ortp_set_log_thread_id(unsigned long thread_id) {
	if (thread_id == 0) {
		ortp_logv_flush();
		ortp_mutex_destroy(&__log_stored_messages_mutex);
	} else {
		ortp_mutex_init(&__log_stored_messages_mutex, NULL);
	}
	__log_thread_id = thread_id;
}
Exemplo n.º 2
0
void ortp_logv(int level, const char *fmt, va_list args) {
	if ((ortp_logv_out != NULL) && ortp_log_level_enabled(level)) {
		if (__log_thread_id == 0) {
			ortp_logv_out(level, fmt, args);
		} else if (__log_thread_id == ortp_thread_self()) {
			ortp_logv_flush();
			ortp_logv_out(level, fmt, args);
		} else {
			ortp_stored_log_t *l = ortp_new(ortp_stored_log_t, 1);
			l->level = level;
			l->msg = ortp_strdup_vprintf(fmt, args);
			ortp_mutex_lock(&__log_stored_messages_mutex);
			__log_stored_messages_list = o_list_append(__log_stored_messages_list, l);
			ortp_mutex_unlock(&__log_stored_messages_mutex);
		}
	}
#if !defined(_WIN32_WCE)
	if (level == ORTP_FATAL) {
		ortp_logv_flush();
		abort();
	}
#endif
}