diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-11-05 22:49:23 +0000 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2016-01-18 20:46:10 +0100 |
commit | 35f4e5dccb6aaa818a53bb6b12acb1c1a2f3b465 (patch) | |
tree | c7f0c0e66870f72aa283db20c23d62152cac9fd8 /daemon/daemon-main.c | |
parent | 4af662dce03afbf9cd12f73b17a74cf10f9dd47b (diff) | |
download | gvfs-35f4e5dccb6aaa818a53bb6b12acb1c1a2f3b465.tar.gz |
daemon: Allow toggling debug output with SIGUSR2
With dbus hooked up to systemd, it can be useful to toggle debug output
on/off for a running daemon. Respond to SIGUSR2 by toggling debug
output.
E.g. to toggle and then watch debug output on a running sftp mount:
$ pkill -USR2 gvfsd-sftp
$ journalctl -f
https://bugzilla.gnome.org/show_bug.cgi?id=740660
Diffstat (limited to 'daemon/daemon-main.c')
-rw-r--r-- | daemon/daemon-main.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/daemon/daemon-main.c b/daemon/daemon-main.c index 600921ce..a81313d1 100644 --- a/daemon/daemon-main.c +++ b/daemon/daemon-main.c @@ -33,11 +33,11 @@ #include <gvfsdaemon.h> #include <gvfsbackend.h> #include <gvfsdbus.h> +#include <gvfsutils.h> static char *spawner_id = NULL; static char *spawner_path = NULL; -static gboolean print_debug = FALSE; static gboolean already_acquired = FALSE; static int process_result = 0; @@ -50,7 +50,7 @@ log_debug (const gchar *log_domain, const gchar *message, gpointer unused_data) { - if (print_debug) + if (gvfs_get_debug ()) g_print ("%s", message); } @@ -68,6 +68,8 @@ daemon_init (void) g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, log_debug, NULL); + gvfs_setup_debug_handler (); + #ifdef SIGPIPE /* Ignore SIGPIPE to avoid killing daemons on cancelled transfer * * See https://bugzilla.gnome.org/show_bug.cgi?id=649041 * @@ -217,13 +219,13 @@ daemon_parse_args (int argc, char *argv[], const char *default_type) if (argc > 1 && strcmp (argv[1], "--debug") == 0) { - print_debug = TRUE; + gvfs_set_debug (TRUE); argc--; argv++; } else if (g_getenv ("GVFS_DEBUG")) { - print_debug = TRUE; + gvfs_set_debug (TRUE); } mount_spec = NULL; |