Merge lp://qastaging/~dbarth/xsplash/xsplash-log into lp://qastaging/xsplash

Proposed by David Barth
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~dbarth/xsplash/xsplash-log
Merge into: lp://qastaging/xsplash
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~dbarth/xsplash/xsplash-log
Reviewer Review Type Date Requested Status
Cody Russell (community) Disapprove
Ken VanDine Needs Information
Review via email: mp+10449@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

This branch contains support for logging messages (with timings) into a file, to help with adjusting xsplash with various environments. Should be useful to collect debug informations in the field.

47. By David Barth

bug fix: avoid crashing in the absence of a valid throbber image (pixbuf)

48. By David Barth

log any of SIG{HUP,INT,TERM} and exit

49. By David Barth

extra debug messages

50. By David Barth

fix for throbber file not being installed

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

I would rather not write the log into /tmp, it might get cleaned up on us before we need it. I would suggest /var/log/gdm/xsplash.log, since we are running as the gdm user.

review: Needs Information
Revision history for this message
Cody Russell (bratsche) wrote :

I branched this to fix the logfile name as Ken suggested, and fixed the style/indentation to be like the rest of xsplash.

review: Disapprove

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 'src/Makefile.am'
16--- src/Makefile.am 2009-08-19 00:44:34 +0000
17+++ src/Makefile.am 2009-08-20 09:38:11 +0000
18@@ -10,6 +10,7 @@
19
20 sources_h = \
21 gtytimeline.h \
22+ log.h \
23 xsplash.h
24
25 EXTRA_DIST = \
26@@ -58,6 +59,7 @@
27 dbus-xsplash-server.h \
28 gtytypebuiltins.c \
29 gtytimeline.c \
30+ log.c \
31 xsplash.c
32
33 xsplash_LDFLAGS = \
34
35=== added file 'src/log.c'
36--- src/log.c 1970-01-01 00:00:00 +0000
37+++ src/log.c 2009-08-20 09:38:11 +0000
38@@ -0,0 +1,118 @@
39+/*******************************************************************************
40+**
41+** log.c - log utils
42+**
43+** Copyright 2009 Canonical Ltd.
44+**
45+** Authors:
46+** Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
47+** David Barth <david.barth@canonical.com>
48+**
49+** This program is free software: you can redistribute it and/or modify it
50+** under the terms of the GNU General Public License version 3, as published
51+** by the Free Software Foundation.
52+**
53+** This program is distributed in the hope that it will be useful, but
54+** WITHOUT ANY WARRANTY; without even the implied warranties of
55+** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
56+** PURPOSE. See the GNU General Public License for more details.
57+**
58+** You should have received a copy of the GNU General Public License along
59+** with this program. If not, see <http://www.gnu.org/licenses/>.
60+**
61+*******************************************************************************/
62+
63+#include "config.h"
64+#include <sys/time.h>
65+#include <time.h>
66+#include <stdio.h>
67+
68+#include <glib-object.h>
69+
70+static FILE *logfile = NULL;
71+
72+static void
73+log_logger_null(const char *domain,
74+ GLogLevelFlags log_level,
75+ const char *message,
76+ gpointer user_data)
77+{
78+ return;
79+}
80+
81+char*
82+log_create_timestamp (void)
83+{
84+ struct timeval tv;
85+ struct tm *tm;
86+
87+ /* FIXME: deal with tz offsets */
88+ gettimeofday (&tv, NULL);
89+ tm = localtime (&tv.tv_sec);
90+
91+ return g_strdup_printf ("%.2d:%.2d:%.2d:%.6ld",
92+ tm->tm_hour, tm->tm_min, tm->tm_sec,
93+ tv.tv_usec - tv.tv_sec * G_USEC_PER_SEC);
94+}
95+
96+void log_logger_file (const gchar *log_domain,
97+ GLogLevelFlags log_level,
98+ const gchar *message,
99+ gpointer data)
100+{
101+ if (logfile == NULL)
102+ return;
103+
104+ char *ts = log_create_timestamp ();
105+ char *level_str = NULL;
106+
107+ if (log_level & G_LOG_LEVEL_DEBUG)
108+ level_str = "DBG";
109+
110+ if (log_level & G_LOG_LEVEL_INFO)
111+ level_str = "INF";
112+
113+ if (log_level & G_LOG_LEVEL_MESSAGE)
114+ level_str = "MSG";
115+
116+ if (log_level & G_LOG_LEVEL_WARNING)
117+ level_str = "WRN";
118+
119+ if (log_level & G_LOG_LEVEL_CRITICAL)
120+ level_str = "CRI";
121+
122+ if (log_level & G_LOG_LEVEL_ERROR)
123+ level_str = "ERR";
124+
125+ fprintf (logfile, "[%s - %s] %s\n",
126+ ts, level_str, message);
127+
128+ fflush (logfile);
129+
130+ g_free (ts);
131+}
132+
133+void
134+log_init (const char *filename)
135+{
136+ /* the file is truncated at every run */
137+ logfile = fopen (filename, "w");
138+ if (logfile == NULL)
139+ g_warning ("could not open/append to %s; logging disabled", filename);
140+
141+ g_log_set_handler (G_LOG_DOMAIN,
142+ G_LOG_LEVEL_MASK
143+ | G_LOG_FLAG_FATAL
144+ | G_LOG_FLAG_RECURSION,
145+ log_logger_file,
146+ NULL);
147+
148+ /* discard all debug messages unless DEBUG is set */
149+ if (! g_getenv ("DEBUG"))
150+ g_log_set_handler (NULL,
151+ G_LOG_LEVEL_DEBUG,
152+ log_logger_null, NULL);
153+ else
154+ g_message ("DEBUG mode enabled");
155+}
156+
157
158=== added file 'src/log.h'
159--- src/log.h 1970-01-01 00:00:00 +0000
160+++ src/log.h 2009-08-20 09:38:11 +0000
161@@ -0,0 +1,35 @@
162+/*******************************************************************************
163+**
164+** log.h - log utils
165+**
166+** Copyright 2009 Canonical Ltd.
167+**
168+** Authors:
169+** Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
170+** David Barth <david.barth@canonical.com>
171+**
172+** This program is free software: you can redistribute it and/or modify it
173+** under the terms of the GNU General Public License version 3, as published
174+** by the Free Software Foundation.
175+**
176+** This program is distributed in the hope that it will be useful, but
177+** WITHOUT ANY WARRANTY; without even the implied warranties of
178+** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
179+** PURPOSE. See the GNU General Public License for more details.
180+**
181+** You should have received a copy of the GNU General Public License along
182+** with this program. If not, see <http://www.gnu.org/licenses/>.
183+**
184+*******************************************************************************/
185+
186+#ifndef __CANONICAL_LOG_H
187+#define __CANONICAL_LOG_H
188+
189+G_BEGIN_DECLS
190+
191+void
192+log_init (const char *filename);
193+
194+G_END_DECLS
195+
196+#endif /* __CANONICAL_LOG_H */
197
198=== modified file 'src/xsplash.c'
199--- src/xsplash.c 2009-08-19 15:59:17 +0000
200+++ src/xsplash.c 2009-08-20 09:38:11 +0000
201@@ -30,6 +30,7 @@
202
203 #include "gtytimeline.h"
204 #include "xsplash.h"
205+#include "log.h"
206
207 typedef struct _AnimContext AnimContext;
208 typedef struct _XsplashServerPrivate XsplashServerPrivate;
209@@ -520,6 +521,8 @@
210 return FALSE;
211 }
212
213+#define XSPLASH_LOG "/tmp/.xsplash.log"
214+
215 int
216 main (int argc, char *argv[])
217 {
218@@ -542,6 +545,8 @@
219
220 gtk_init (&argc, &argv);
221
222+ log_init (XSPLASH_LOG); g_message ("xsplash started");
223+
224 if (background_image == NULL)
225 background_image = g_strdup ("/usr/share/backgrounds/warty-final-ubuntu.png");
226
227@@ -551,6 +556,10 @@
228 if (throbber_image == NULL)
229 throbber_image = g_strdup (DATADIR "/images/xsplash/xsplash-throbber.png");
230
231+ g_debug ("background_image = %s", background_image);
232+ g_debug ("logo_image = %s", logo_image);
233+ g_debug ("throbber_image = %s", throbber_image);
234+
235 system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
236 bus_proxy = dbus_g_proxy_new_for_name (system_bus,
237 DBUS_SERVICE_DBUS,

Subscribers

People subscribed via source and target branches