]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
have Seat implement the Logger interface
authora7x <ubuntu-a7x@scientician.org>
Wed, 14 Aug 2013 20:14:16 +0000 (16:14 -0400)
committera7x <ubuntu-a7x@scientician.org>
Wed, 14 Aug 2013 20:14:16 +0000 (16:14 -0400)
This is a step toward logging the seat name in each Seat log message,
which will make it easier to debug multiseat setups.

src/seat.c
src/seat.h

index c035bce44eca14596639543b05927376af35e483..efc8b5ed7a2038cce3602264e332331d91f3fc29 100644 (file)
@@ -66,7 +66,11 @@ struct SeatPrivate
 #define USER_SERVICE      "lightdm"
 #define AUTOLOGIN_SERVICE "lightdm-autologin"
 
-G_DEFINE_TYPE (Seat, seat, G_TYPE_OBJECT);
+static void seat_logger_iface_init (LoggerInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (Seat, seat, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (
+                             LOGGER_TYPE, seat_logger_iface_init));
 
 typedef struct
 {
@@ -1621,3 +1625,20 @@ seat_class_init (SeatClass *klass)
                       NULL,
                       G_TYPE_NONE, 0);
 }
+
+static gint
+seat_real_logprefix (Logger *self, gchar *buf, gulong buflen)
+{
+    Seat *seat = SEAT (self);
+    const gchar *name = seat_get_string_property (seat, "seat-name");
+    if (name)
+        return g_snprintf (buf, buflen, "Seat %s: ", name);
+    else
+        return g_snprintf (buf, buflen, "Seat: ");
+}
+
+static void
+seat_logger_iface_init (LoggerInterface *iface)
+{
+    iface->logprefix = &seat_real_logprefix;
+}
index 94d3341dc7185adeb29abb18655cd3a5b64bfaf9..a5ebec5c6472a2c9fba6d7e325a72aacc0d027a7 100644 (file)
@@ -17,6 +17,7 @@
 #include "greeter.h"
 #include "session.h"
 #include "process.h"
+#include "logger.h"
 
 G_BEGIN_DECLS