log: use temporary log first

Use the default log implementation as a default log until a more
complete one is installed. This way we get log early.
This commit is contained in:
Wim Taymans 2019-06-21 13:29:52 +02:00
parent 5b7e95c71c
commit 4494f9c7c9

View file

@ -22,14 +22,18 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include <spa/support/log-impl.h>
#include <pipewire/log.h> #include <pipewire/log.h>
SPA_LOG_IMPL(default_log);
#define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_ERROR #define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_ERROR
SPA_EXPORT SPA_EXPORT
enum spa_log_level pw_log_level = DEFAULT_LOG_LEVEL; enum spa_log_level pw_log_level = DEFAULT_LOG_LEVEL;
static struct spa_log *global_log = NULL; static struct spa_log *global_log = &default_log.log;
/** Set the global log interface /** Set the global log interface
* \param log the global log to set * \param log the global log to set
@ -83,7 +87,7 @@ pw_log_log(enum spa_log_level level,
const char *func, const char *func,
const char *fmt, ...) const char *fmt, ...)
{ {
if (SPA_UNLIKELY(pw_log_level_enabled(level) && global_log)) { if (SPA_UNLIKELY(pw_log_level_enabled(level))) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
spa_interface_call(&global_log->iface, spa_interface_call(&global_log->iface,
@ -112,7 +116,7 @@ pw_log_logv(enum spa_log_level level,
const char *fmt, const char *fmt,
va_list args) va_list args)
{ {
if (SPA_UNLIKELY(pw_log_level_enabled(level) && global_log)) { if (SPA_UNLIKELY(pw_log_level_enabled(level))) {
spa_interface_call(&global_log->iface, spa_interface_call(&global_log->iface,
struct spa_log_methods, logv, 0, level, file, line, struct spa_log_methods, logv, 0, level, file, line,
func, fmt, args); func, fmt, args);