Merge lp://qastaging/~bratsche/xsplash/log into lp://qastaging/xsplash

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~bratsche/xsplash/log
Merge into: lp://qastaging/xsplash
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~bratsche/xsplash/log
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Canonical Desktop Experience Team Pending
Review via email: mp+10462@code.qastaging.launchpad.net

Commit message

switch logfile to /var/log/gdm/xsplash.log and fix style

To post a comment you must log in.
Revision history for this message
Cody Russell (bratsche) wrote :

This is a fork of dbarth's xsplash-log branch. Fixes the logfile name and fixes the style to be consistent with the rest of xsplash.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build/autotools/libtool.m4'
2--- build/autotools/libtool.m4 2009-08-04 14:31:23 +0000
3+++ build/autotools/libtool.m4 2009-08-20 09:38:11 +0000
4@@ -4261,9 +4261,6 @@
5 openbsd*)
6 with_gnu_ld=no
7 ;;
8- linux* | k*bsd*-gnu)
9- _LT_TAGVAR(link_all_deplibs, $1)=no
10- ;;
11 esac
12
13 _LT_TAGVAR(ld_shlibs, $1)=yes
14
15=== modified file 'images/Makefile.am'
16--- images/Makefile.am 2009-08-19 00:44:34 +0000
17+++ images/Makefile.am 2009-08-20 11:07:58 +0000
18@@ -1,9 +1,7 @@
19 NULL =
20
21-icondir = $(datadir)/images/xsplash
22-
23-icon_DATA = \
24- xsplash-background.png \
25- xsplash-throbber.png
26-
27-EXTRA_DIST = $(icon_DATA)
28+imagesdir = $(datadir)/images/xsplash
29+
30+images_DATA = xsplash-background.png xsplash-throbber.png
31+
32+EXTRA_DIST = $(images_DATA)
33
34=== modified file 'src/Makefile.am'
35--- src/Makefile.am 2009-08-19 00:44:34 +0000
36+++ src/Makefile.am 2009-08-20 09:38:11 +0000
37@@ -10,6 +10,7 @@
38
39 sources_h = \
40 gtytimeline.h \
41+ log.h \
42 xsplash.h
43
44 EXTRA_DIST = \
45@@ -58,6 +59,7 @@
46 dbus-xsplash-server.h \
47 gtytypebuiltins.c \
48 gtytimeline.c \
49+ log.c \
50 xsplash.c
51
52 xsplash_LDFLAGS = \
53
54=== added file 'src/log.c'
55--- src/log.c 1970-01-01 00:00:00 +0000
56+++ src/log.c 2009-08-20 14:50:02 +0000
57@@ -0,0 +1,120 @@
58+/*
59+ * log.c - log utils
60+ *
61+ * Copyright 2009 Canonical Ltd.
62+ *
63+ * Authors:
64+ * Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
65+ * David Barth <david.barth@canonical.com>
66+ *
67+ * This program is free software: you can redistribute it and/or modify it
68+ * under the terms of the GNU General Public License version 3, as published
69+ * by the Free Software Foundation.
70+ *
71+ * This program is distributed in the hope that it will be useful, but
72+ * WITHOUT ANY WARRANTY; without even the implied warranties of
73+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
74+ * PURPOSE. See the GNU General Public License for more details.
75+ *
76+ * You should have received a copy of the GNU General Public License along
77+ * with this program. If not, see <http://www.gnu.org/licenses/>.
78+ */
79+
80+#include "config.h"
81+#include <sys/time.h>
82+#include <time.h>
83+#include <stdio.h>
84+
85+#include <glib-object.h>
86+
87+static FILE *logfile = NULL;
88+
89+static void
90+log_logger_null (const char *domain,
91+ GLogLevelFlags log_level,
92+ const char *message,
93+ gpointer user_data)
94+{
95+ return;
96+}
97+
98+char*
99+log_create_timestamp (void)
100+{
101+ struct timeval tv;
102+ struct tm *tm;
103+
104+ /* FIXME: deal with tz offsets */
105+ gettimeofday (&tv, NULL);
106+ tm = localtime (&tv.tv_sec);
107+
108+ return g_strdup_printf ("%.2d:%.2d:%.2d:%.6ld",
109+ tm->tm_hour, tm->tm_min, tm->tm_sec,
110+ tv.tv_usec - tv.tv_sec * G_USEC_PER_SEC);
111+}
112+
113+void
114+log_logger_file (const gchar *log_domain,
115+ GLogLevelFlags log_level,
116+ const gchar *message,
117+ gpointer data)
118+{
119+ if (logfile == NULL)
120+ return;
121+
122+ char *ts = log_create_timestamp ();
123+ char *level_str = NULL;
124+
125+ if (log_level & G_LOG_LEVEL_DEBUG)
126+ level_str = "DBG";
127+
128+ if (log_level & G_LOG_LEVEL_INFO)
129+ level_str = "INF";
130+
131+ if (log_level & G_LOG_LEVEL_MESSAGE)
132+ level_str = "MSG";
133+
134+ if (log_level & G_LOG_LEVEL_WARNING)
135+ level_str = "WRN";
136+
137+ if (log_level & G_LOG_LEVEL_CRITICAL)
138+ level_str = "CRI";
139+
140+ if (log_level & G_LOG_LEVEL_ERROR)
141+ level_str = "ERR";
142+
143+ fprintf (logfile, "[%s - %s] %s\n",
144+ ts, level_str, message);
145+
146+ fflush (logfile);
147+
148+ g_free (ts);
149+}
150+
151+void
152+log_init (const char *filename)
153+{
154+ /* the file is truncated at every run */
155+ logfile = fopen (filename, "w");
156+
157+ if (logfile == NULL)
158+ g_warning ("could not open/append to %s; logging disabled", filename);
159+
160+ g_log_set_handler (G_LOG_DOMAIN,
161+ G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
162+ log_logger_file,
163+ NULL);
164+
165+ /* discard all debug messages unless DEBUG is set */
166+ if (! g_getenv ("DEBUG"))
167+ {
168+ g_log_set_handler (NULL,
169+ G_LOG_LEVEL_DEBUG,
170+ log_logger_null, NULL);
171+ }
172+ else
173+ {
174+ g_message ("DEBUG mode enabled");
175+ }
176+}
177+
178
179=== added file 'src/log.h'
180--- src/log.h 1970-01-01 00:00:00 +0000
181+++ src/log.h 2009-08-20 14:50:02 +0000
182@@ -0,0 +1,32 @@
183+/*
184+ * log.h - log utils
185+ *
186+ * Copyright 2009 Canonical Ltd.
187+ *
188+ * Authors:
189+ * Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
190+ * David Barth <david.barth@canonical.com>
191+ *
192+ * This program is free software: you can redistribute it and/or modify it
193+ * under the terms of the GNU General Public License version 3, as published
194+ * by the Free Software Foundation.
195+ *
196+ * This program is distributed in the hope that it will be useful, but
197+ * WITHOUT ANY WARRANTY; without even the implied warranties of
198+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
199+ * PURPOSE. See the GNU General Public License for more details.
200+ *
201+ * You should have received a copy of the GNU General Public License along
202+ * with this program. If not, see <http://www.gnu.org/licenses/>.
203+ */
204+
205+#ifndef __XSPLASH_LOG_H__
206+#define __XSPLASH_LOG_H__
207+
208+G_BEGIN_DECLS
209+
210+void log_init (const char *filename);
211+
212+G_END_DECLS
213+
214+#endif /* __XSPLASH_LOG_H__ */
215
216=== modified file 'src/xsplash.c'
217--- src/xsplash.c 2009-08-19 15:59:17 +0000
218+++ src/xsplash.c 2009-08-20 14:50:02 +0000
219@@ -30,6 +30,7 @@
220
221 #include "gtytimeline.h"
222 #include "xsplash.h"
223+#include "log.h"
224
225 typedef struct _AnimContext AnimContext;
226 typedef struct _XsplashServerPrivate XsplashServerPrivate;
227@@ -323,6 +324,8 @@
228 if (throbber_image && throbber_frames)
229 {
230 priv->throbber_pixbuf = gdk_pixbuf_new_from_file (throbber_image, NULL);
231+ if (priv->throbber_pixbuf != NULL)
232+ {
233 priv->throbber = gtk_image_new ();
234 gtk_widget_show (priv->throbber);
235
236@@ -330,6 +333,11 @@
237 gdk_pixbuf_get_width (pixbuf) / 2 - gdk_pixbuf_get_width (priv->throbber_pixbuf) / 2,
238 gdk_pixbuf_get_height (pixbuf) / 3 + gdk_pixbuf_get_height (logo) + gdk_pixbuf_get_height (priv->throbber_pixbuf) / ((throbber_frames - 1) * 2));
239 start_throbber (server);
240+ }
241+ else
242+ g_debug ("couldn't load throbber image from file (%s); "
243+ "disabling throbber", throbber_image);
244+
245 }
246
247 gtk_container_add (GTK_CONTAINER (priv->window), fixed);
248@@ -388,6 +396,8 @@
249 server);
250
251 gty_timeline_start (timeline);
252+
253+ g_debug ("throbber started (%d frames)", throbber_frames);
254 }
255
256 static void
257@@ -430,6 +440,7 @@
258 switch (event->keyval)
259 {
260 case GDK_Escape:
261+ g_debug ("ESC interrupt");
262 begin_fade (server, TRUE);
263
264 /* else queue another fade? */
265@@ -494,6 +505,8 @@
266
267 anim_context_free (context);
268
269+ g_debug ("fade finished");
270+
271 if (context->exit_on_finish)
272 {
273 gtk_main_quit ();
274@@ -515,11 +528,23 @@
275 {
276 XsplashServer *server = (XsplashServer *)user_data;
277
278+ g_debug ("** timeout **");
279+
280 begin_fade (server, TRUE);
281
282 return FALSE;
283 }
284
285+void
286+sig_handler (int signum)
287+{
288+ g_debug ("** interrupted **");
289+ gtk_main_quit ();
290+}
291+
292+
293+#define XSPLASH_LOG "/var/log/gdm/xsplash.log"
294+
295 int
296 main (int argc, char *argv[])
297 {
298@@ -542,6 +567,12 @@
299
300 gtk_init (&argc, &argv);
301
302+ log_init (XSPLASH_LOG); g_message ("xsplash started");
303+
304+ signal (SIGHUP, sig_handler);
305+ signal (SIGINT, sig_handler);
306+ signal (SIGTERM, sig_handler);
307+
308 if (background_image == NULL)
309 background_image = g_strdup ("/usr/share/backgrounds/warty-final-ubuntu.png");
310
311@@ -551,6 +582,10 @@
312 if (throbber_image == NULL)
313 throbber_image = g_strdup (DATADIR "/images/xsplash/xsplash-throbber.png");
314
315+ g_debug ("background_image = %s", background_image);
316+ g_debug ("logo_image = %s", logo_image);
317+ g_debug ("throbber_image = %s", throbber_image);
318+
319 system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
320 bus_proxy = dbus_g_proxy_new_for_name (system_bus,
321 DBUS_SERVICE_DBUS,
322@@ -583,6 +618,8 @@
323
324 gtk_main ();
325
326+ g_debug ("exiting...");
327+
328 if (background_image != NULL)
329 g_free (background_image);
330
331@@ -602,8 +639,11 @@
332 {
333 XsplashServerPrivate *priv = XSPLASH_SERVER_GET_PRIVATE (server);
334
335+ g_debug ("received signal: %s", app);
336+
337 if (gdm_session)
338 {
339+ g_debug ("gdm mode: fading out");
340 begin_fade (server, TRUE);
341 }
342 else
343@@ -619,6 +659,7 @@
344
345 if (priv->nautilus_done && priv->panel_done)
346 {
347+ g_debug ("received both \"nautilus\" and \"panel\" signals: fading out");
348 begin_fade (server, TRUE);
349 }
350 }

Subscribers

People subscribed via source and target branches