Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon: Add a logging function for libblockdev #1326

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/udisksdaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,34 @@ check_modules_state_in_idle_cb (gpointer user_data)
return G_SOURCE_REMOVE;
}

static void
bd_log_redirect (gint level, const gchar *msg)
{
switch (level)
{
case BD_UTILS_LOG_EMERG:
case BD_UTILS_LOG_ALERT:
case BD_UTILS_LOG_CRIT:
case BD_UTILS_LOG_ERR:
udisks_critical ("[blockdev] %s", msg);
break;
case BD_UTILS_LOG_WARNING:
udisks_warning ("[blockdev] %s", msg);
break;
case BD_UTILS_LOG_NOTICE:
udisks_notice ("[blockdev] %s", msg);
break;
case BD_UTILS_LOG_INFO:
udisks_info ("[blockdev] %s", msg);
break;
case BD_UTILS_LOG_DEBUG:
udisks_debug ("[blockdev] %s", msg);
break;
default:
break;
}
}

static void
udisks_daemon_constructed (GObject *object)
{
Expand Down Expand Up @@ -342,7 +370,7 @@ udisks_daemon_constructed (GObject *object)
BDPluginSpec **plugin_p = NULL;
error = NULL;

ret = bd_try_init (plugins, NULL, NULL, &error);
ret = bd_try_init (plugins, bd_log_redirect, NULL, &error);
if (!ret)
{
if (error)
Expand All @@ -360,6 +388,12 @@ udisks_daemon_constructed (GObject *object)
}
}

#ifdef DEBUG
bd_utils_set_log_level(BD_UTILS_LOG_DEBUG);
#else
bd_utils_set_log_level(BD_UTILS_LOG_INFO);
#endif

/* Generate global UUID */
uuid_generate (uuid);
uuid_unparse (uuid, &uuid_buf[0]);
Expand Down