Skip to content

Commit 5d79d06

Browse files
committed
daemon-skeleton: Try to fix verbose mode again...
1 parent 3298eae commit 5d79d06

2 files changed

Lines changed: 16 additions & 40 deletions

File tree

plugins/common/daemon-skeleton-gtk.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,29 +179,20 @@ handle_signal (gpointer user_data)
179179
return G_SOURCE_REMOVE;
180180
}
181181

182-
static void
183-
message_handler (const gchar *log_domain,
184-
GLogLevelFlags log_level,
185-
const gchar *message,
186-
gpointer user_data)
187-
{
188-
/* Make this look like normal console output */
189-
if (log_level & G_LOG_LEVEL_DEBUG) {
190-
g_autoptr(GDateTime) dt = g_date_time_new_now_local ();
191-
g_autofree gchar *iso8601 = g_date_time_format (dt, "%F:%T");
192-
printf ("csd-%s:%s: %s\n", PLUGIN_NAME, iso8601, message);
193-
}
194-
else {
195-
printf ("%s: %s\n", g_get_prgname (), message);
196-
}
197-
}
198-
199182
int
200183
main (int argc, char **argv)
201184
{
202185
GError *error;
203186
gboolean started;
204187

188+
for (int i = 1; i < argc; i++) {
189+
if (g_strcmp0 (argv[i], "--verbose") == 0 || g_strcmp0 (argv[i], "-v") == 0) {
190+
verbose = TRUE;
191+
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
192+
break;
193+
}
194+
}
195+
205196
bindtextdomain (GETTEXT_PACKAGE, CINNAMON_SETTINGS_LOCALEDIR);
206197
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
207198
textdomain (GETTEXT_PACKAGE);
@@ -242,9 +233,6 @@ main (int argc, char **argv)
242233

243234
g_unix_signal_add (SIGTERM, (GSourceFunc) handle_signal, NULL);
244235

245-
if (verbose)
246-
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL);
247-
248236
if (timeout > 0) {
249237
guint id;
250238
id = g_timeout_add_seconds (timeout, (GSourceFunc) gtk_main_quit, NULL);

plugins/common/daemon-skeleton.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,6 @@ handle_signal (gpointer user_data)
176176
return G_SOURCE_REMOVE;
177177
}
178178

179-
static void
180-
message_handler (const gchar *log_domain,
181-
GLogLevelFlags log_level,
182-
const gchar *message,
183-
gpointer user_data)
184-
{
185-
/* Make this look like normal console output */
186-
if (log_level & G_LOG_LEVEL_DEBUG) {
187-
g_autoptr(GDateTime) dt = g_date_time_new_now_local ();
188-
g_autofree gchar *iso8601 = g_date_time_format (dt, "%F:%T");
189-
printf ("csd-%s:%s: %s\n", PLUGIN_NAME, iso8601, message);
190-
}
191-
else {
192-
printf ("%s: %s\n", g_get_prgname (), message);
193-
}
194-
}
195-
196179
int
197180
main (int argc, char **argv)
198181
{
@@ -202,6 +185,14 @@ main (int argc, char **argv)
202185
GMainLoop *loop;
203186

204187

188+
for (int i = 1; i < argc; i++) {
189+
if (g_strcmp0 (argv[i], "--verbose") == 0 || g_strcmp0 (argv[i], "-v") == 0) {
190+
verbose = TRUE;
191+
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
192+
break;
193+
}
194+
}
195+
205196
bindtextdomain (GETTEXT_PACKAGE, CINNAMON_SETTINGS_LOCALEDIR);
206197
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
207198
textdomain (GETTEXT_PACKAGE);
@@ -230,9 +221,6 @@ main (int argc, char **argv)
230221

231222
g_unix_signal_add (SIGTERM, (GSourceFunc) handle_signal, loop);
232223

233-
if (verbose)
234-
g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL);
235-
236224
if (timeout > 0) {
237225
guint id;
238226
id = g_timeout_add_seconds (timeout, (GSourceFunc) g_main_loop_quit, loop);

0 commit comments

Comments
 (0)