wpexec: force the log level to be at least 1 and use fprintf() for local errors

pipewire's client.conf sets the default log level to 0, which is not
good for wpexec, as lua runtime errors are reported as warnings currently.

Also, let's use fprintf() for local cli errors to make sure they get printed
even if the log level is 0
This commit is contained in:
George Kiagiadakis 2021-06-08 19:28:26 +03:00
parent 31f56c7be5
commit aa618e99cb
2 changed files with 10 additions and 3 deletions

View file

@ -354,7 +354,7 @@ main (gint argc, gchar **argv)
context = g_option_context_new ("- PipeWire Session/Policy Manager");
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
wp_message ("%s", error->message);
fprintf (stderr, "%s\n", error->message);
return WP_CODE_INVALID_ARGUMENT;
}

View file

@ -9,6 +9,7 @@
#include <wp/wp.h>
#include <glib-unix.h>
#include <pipewire/keys.h>
#include <stdio.h>
#define WP_DOMAIN_DAEMON (wp_domain_daemon_quark ())
static G_DEFINE_QUARK (wireplumber-daemon, wp_domain_daemon);
@ -202,7 +203,7 @@ init_done (WpCore * core, GAsyncResult * res, WpExec * d)
{
g_autoptr (GError) error = NULL;
if (!wp_transition_finish (res, &error)) {
wp_message ("%s", error->message);
fprintf (stderr, "%s\n", error->message);
d->exit_code = WP_CODE_OPERATION_FAILED;
g_main_loop_quit (d->loop);
}
@ -220,7 +221,7 @@ main (gint argc, gchar **argv)
context = g_option_context_new ("- WirePlumber script interpreter");
g_option_context_add_main_entries (context, entries, NULL);
if (!g_option_context_parse (context, &argc, &argv, &error)) {
wp_message ("%s", error->message);
fprintf (stderr, "%s\n", error->message);
return WP_CODE_INVALID_ARGUMENT;
}
@ -232,6 +233,12 @@ main (gint argc, gchar **argv)
g_signal_connect_swapped (d.core, "disconnected",
G_CALLBACK (g_main_loop_quit), d.loop);
/* at the very least, enable warnings...
this is required to spot lua runtime errors, otherwise
there is silence and nothing is happening */
if (!wp_log_level_is_enabled (G_LOG_LEVEL_WARNING))
wp_log_set_level ("1");
/* watch for exit signals */
g_unix_signal_add (SIGINT, signal_handler, &d);
g_unix_signal_add (SIGTERM, signal_handler, &d);