gtk: Capture new-style GLib structured logging messages under d-i
GLib 2.50 replaced the non-machine-readable, text-based logging that
uses g_log_set_default_handler() with a more structured logging
framework inspired by systemd-journal. Each library can either use the
structured or unstructured logging framework; unstructured messages are
received by structured log handlers, but the opposite is not true.
For the purposes of this debconf frontend, the interesting libraries
include GLib and Pango (which use structured logging) and GTK 2
(which does not). As a result, GLib and Pango debug messages did not
go to the syslog in d-i; now they do.
Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #988589
Simon McVittie
2 years ago
7 | 7 |
libnewt-dev,
|
8 | 8 |
libtextwrap-dev (>= 0.1-5),
|
9 | 9 |
libdebian-installer4-dev (>= 0.41) | libdebian-installer-dev,
|
10 | |
libglib2.0-dev (>= 2.31),
|
|
10 |
libglib2.0-dev (>= 2.50),
|
11 | 11 |
libgtk2.0-dev (>= 2.24) <!pkg.cdebconf.nogtk>,
|
12 | 12 |
libcairo2-dev (>= 1.8.10-3) <!pkg.cdebconf.nogtk>,
|
13 | 13 |
libselinux1-dev (>= 2.3) [linux-any] | libselinux-dev [linux-any],
|
141 | 141 |
g_free(string);
|
142 | 142 |
}
|
143 | 143 |
|
|
144 |
/** Implementation of GLogFunc for the GTK+ frontend.
|
|
145 |
*
|
|
146 |
* This will log messages going through the glib log system to the standard
|
|
147 |
* syslog.
|
|
148 |
*
|
|
149 |
* @param log_domain the log domain of the message
|
|
150 |
* @param log_level the log level of the message
|
|
151 |
* @param message the message to process
|
|
152 |
* @param user_data user data, set in g_log_set_handler()
|
|
153 |
*/
|
|
154 |
static GLogWriterOutput log_glib_structured_to_syslog(GLogLevelFlags log_level,
|
|
155 |
const GLogField *fields,
|
|
156 |
gsize n_fields,
|
|
157 |
gpointer user_data)
|
|
158 |
{
|
|
159 |
const char *domain = NULL;
|
|
160 |
const char *message = "(no message)";
|
|
161 |
gsize i;
|
|
162 |
|
|
163 |
for (i = 0; i < n_fields; i++) {
|
|
164 |
const GLogField *field = &fields[i];
|
|
165 |
|
|
166 |
if (g_strcmp0(field->key, "MESSAGE") == 0) {
|
|
167 |
message = field->value;
|
|
168 |
}
|
|
169 |
else if (g_strcmp0(field->key, "GLIB_DOMAIN") == 0) {
|
|
170 |
domain = field->value;
|
|
171 |
}
|
|
172 |
}
|
|
173 |
|
|
174 |
log_glib_to_syslog(domain, log_level, message, NULL);
|
|
175 |
return G_LOG_WRITER_HANDLED;
|
|
176 |
}
|
|
177 |
|
144 | 178 |
/** Make the given window fullscreen.
|
145 | 179 |
*
|
146 | 180 |
* @param window main window
|
|
286 | 320 |
fe_data->di_data = di_data;
|
287 | 321 |
|
288 | 322 |
(void) g_set_printerr_handler(print_to_syslog);
|
289 | |
(void) g_log_set_default_handler(log_glib_to_syslog, NULL);
|
|
323 |
g_log_set_writer_func(log_glib_structured_to_syslog, NULL, NULL);
|
290 | 324 |
|
291 | 325 |
make_fullscreen(fe_data->window);
|
292 | 326 |
set_shortcuts(fe);
|