|
|
580c05 |
From 61233d3703071993a1505570de765d8ef1bf7ee2 Mon Sep 17 00:00:00 2001
|
|
|
580c05 |
From: Colin Walters <walters@verbum.org>
|
|
|
580c05 |
Date: Fri, 13 Feb 2015 04:27:27 -0500
|
|
|
580c05 |
Subject: [PATCH 1/2] Drop use of libgsystem, move single API call into
|
|
|
580c05 |
shell-global.c
|
|
|
580c05 |
|
|
|
580c05 |
See https://mail.gnome.org/archives/desktop-devel-list/2015-February/msg00121.html
|
|
|
580c05 |
|
|
|
580c05 |
We presently only indirectly link to it via this one call; until GLib
|
|
|
580c05 |
gains structured logging, simply import the code to wrap the journal
|
|
|
580c05 |
logging in an introspectable API into Shell.
|
|
|
580c05 |
|
|
|
580c05 |
https://bugzilla.gnome.org/show_bug.cgi?id=744457
|
|
|
580c05 |
---
|
|
|
580c05 |
js/ui/main.js | 12 +++---------
|
|
|
580c05 |
src/shell-global.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
580c05 |
src/shell-global.h | 3 +++
|
|
|
580c05 |
3 files changed, 58 insertions(+), 9 deletions(-)
|
|
|
580c05 |
|
|
|
580c05 |
diff --git a/js/ui/main.js b/js/ui/main.js
|
|
|
580c05 |
index 2459069..45df8b4 100644
|
|
|
580c05 |
--- a/js/ui/main.js
|
|
|
580c05 |
+++ b/js/ui/main.js
|
|
|
580c05 |
@@ -208,16 +208,10 @@ function _initializeUI() {
|
|
|
580c05 |
if (screenShield) {
|
|
|
580c05 |
screenShield.lockIfWasLocked();
|
|
|
580c05 |
}
|
|
|
580c05 |
- if (LoginManager.haveSystemd() &&
|
|
|
580c05 |
- sessionMode.currentMode != 'gdm' &&
|
|
|
580c05 |
+ if (sessionMode.currentMode != 'gdm' &&
|
|
|
580c05 |
sessionMode.currentMode != 'initial-setup') {
|
|
|
580c05 |
- // Do not import globally to not depend
|
|
|
580c05 |
- // on systemd on non-systemd systems.
|
|
|
580c05 |
- let GSystem = imports.gi.GSystem;
|
|
|
580c05 |
- GSystem.log_structured_print('GNOME Shell started at ' + _startDate,
|
|
|
580c05 |
- ['MESSAGE_ID=' + GNOMESHELL_STARTED_MESSAGE_ID]);
|
|
|
580c05 |
- } else {
|
|
|
580c05 |
- log('GNOME Shell started at ' + _startDate);
|
|
|
580c05 |
+ Shell.log_structured_print('GNOME Shell started at ' + _startDate,
|
|
|
580c05 |
+ ['MESSAGE_ID=' + GNOMESHELL_STARTED_MESSAGE_ID]);
|
|
|
580c05 |
}
|
|
|
580c05 |
});
|
|
|
580c05 |
}
|
|
|
580c05 |
diff --git a/src/shell-global.c b/src/shell-global.c
|
|
|
580c05 |
index d90ceaf..3a27f31 100644
|
|
|
580c05 |
--- a/src/shell-global.c
|
|
|
580c05 |
+++ b/src/shell-global.c
|
|
|
580c05 |
@@ -28,6 +28,12 @@
|
|
|
580c05 |
#include <meta/meta-shaped-texture.h>
|
|
|
580c05 |
#include <meta/meta-cursor-tracker.h>
|
|
|
580c05 |
|
|
|
580c05 |
+#ifdef HAVE_SYSTEMD
|
|
|
580c05 |
+#include <systemd/sd-journal.h>
|
|
|
580c05 |
+#include <errno.h>
|
|
|
580c05 |
+#include <unistd.h>
|
|
|
580c05 |
+#endif
|
|
|
580c05 |
+
|
|
|
580c05 |
/* Memory report bits */
|
|
|
580c05 |
#ifdef HAVE_MALLINFO
|
|
|
580c05 |
#include <malloc.h>
|
|
|
580c05 |
@@ -1307,6 +1313,52 @@ shell_global_reexec_self (ShellGlobal *global)
|
|
|
580c05 |
}
|
|
|
580c05 |
|
|
|
580c05 |
/**
|
|
|
580c05 |
+ * shell_global_log_structured:
|
|
|
580c05 |
+ * @message: A message to print
|
|
|
580c05 |
+ * @keys: (allow-none) (array zero-terminated=1) (element-type utf8): Optional structured data
|
|
|
580c05 |
+ *
|
|
|
580c05 |
+ * Log structured data in an operating-system specific fashion. The
|
|
|
580c05 |
+ * parameter @opts should be an array of UTF-8 KEY=VALUE strings.
|
|
|
580c05 |
+ * This function does not support binary data. See
|
|
|
580c05 |
+ * http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
|
|
|
580c05 |
+ * or more information about fields that can be used on a systemd
|
|
|
580c05 |
+ * system.
|
|
|
580c05 |
+ *
|
|
|
580c05 |
+ */
|
|
|
580c05 |
+void
|
|
|
580c05 |
+shell_global_log_structured (const char *message,
|
|
|
580c05 |
+ const char *const *keys)
|
|
|
580c05 |
+{
|
|
|
580c05 |
+#ifdef HAVE_SYSTEMD
|
|
|
580c05 |
+ const char *const*iter;
|
|
|
580c05 |
+ char *msgkey;
|
|
|
580c05 |
+ guint i, n_opts;
|
|
|
580c05 |
+ struct iovec *iovs;
|
|
|
580c05 |
+
|
|
|
580c05 |
+ for (n_opts = 0, iter = keys; *iter; iter++, n_opts++)
|
|
|
580c05 |
+ ;
|
|
|
580c05 |
+
|
|
|
580c05 |
+ n_opts++; /* Add one for MESSAGE= */
|
|
|
580c05 |
+ iovs = g_alloca (sizeof (struct iovec) * n_opts);
|
|
|
580c05 |
+
|
|
|
580c05 |
+ for (i = 0, iter = keys; *iter; iter++, i++) {
|
|
|
580c05 |
+ iovs[i].iov_base = (char*)keys[i];
|
|
|
580c05 |
+ iovs[i].iov_len = strlen (keys[i]);
|
|
|
580c05 |
+ }
|
|
|
580c05 |
+ g_assert(i == n_opts-1);
|
|
|
580c05 |
+ msgkey = g_strconcat ("MESSAGE=", message, NULL);
|
|
|
580c05 |
+ iovs[i].iov_base = msgkey;
|
|
|
580c05 |
+ iovs[i].iov_len = strlen (msgkey);
|
|
|
580c05 |
+
|
|
|
580c05 |
+ // The code location isn't useful since we're wrapping
|
|
|
580c05 |
+ sd_journal_sendv (iovs, n_opts);
|
|
|
580c05 |
+ g_free (msgkey);
|
|
|
580c05 |
+#else
|
|
|
580c05 |
+ g_print ("%s\n", message);
|
|
|
580c05 |
+#endif
|
|
|
580c05 |
+}
|
|
|
580c05 |
+
|
|
|
580c05 |
+/**
|
|
|
580c05 |
* shell_global_notify_error:
|
|
|
580c05 |
* @global: a #ShellGlobal
|
|
|
580c05 |
* @msg: Error message
|
|
|
580c05 |
diff --git a/src/shell-global.h b/src/shell-global.h
|
|
|
580c05 |
index a5630ec..25afe17 100644
|
|
|
580c05 |
--- a/src/shell-global.h
|
|
|
580c05 |
+++ b/src/shell-global.h
|
|
|
580c05 |
@@ -126,6 +126,9 @@ void shell_global_init_xdnd (ShellGlobal *global);
|
|
|
580c05 |
|
|
|
580c05 |
void shell_global_reexec_self (ShellGlobal *global);
|
|
|
580c05 |
|
|
|
580c05 |
+void shell_global_log_structured (const char *message,
|
|
|
580c05 |
+ const char *const *keys);
|
|
|
580c05 |
+
|
|
|
580c05 |
const char * shell_global_get_session_mode (ShellGlobal *global);
|
|
|
580c05 |
|
|
|
580c05 |
void shell_global_set_runtime_state (ShellGlobal *global,
|
|
|
580c05 |
--
|
|
|
580c05 |
2.3.6
|
|
|
580c05 |
|
|
|
580c05 |
|
|
|
580c05 |
From 1fe15cf0dbd98afb7b1084c5556f6b6b9a0e62f8 Mon Sep 17 00:00:00 2001
|
|
|
580c05 |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
580c05 |
Date: Fri, 13 Feb 2015 23:02:06 +0100
|
|
|
580c05 |
Subject: [PATCH 2/2] main: Fix structured_log() call
|
|
|
580c05 |
|
|
|
580c05 |
Meh, I should have caught that one in review ...
|
|
|
580c05 |
---
|
|
|
580c05 |
js/ui/main.js | 4 ++--
|
|
|
580c05 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
580c05 |
|
|
|
580c05 |
diff --git a/js/ui/main.js b/js/ui/main.js
|
|
|
580c05 |
index 45df8b4..6865c41 100644
|
|
|
580c05 |
--- a/js/ui/main.js
|
|
|
580c05 |
+++ b/js/ui/main.js
|
|
|
580c05 |
@@ -210,8 +210,8 @@ function _initializeUI() {
|
|
|
580c05 |
}
|
|
|
580c05 |
if (sessionMode.currentMode != 'gdm' &&
|
|
|
580c05 |
sessionMode.currentMode != 'initial-setup') {
|
|
|
580c05 |
- Shell.log_structured_print('GNOME Shell started at ' + _startDate,
|
|
|
580c05 |
- ['MESSAGE_ID=' + GNOMESHELL_STARTED_MESSAGE_ID]);
|
|
|
580c05 |
+ Shell.Global.log_structured('GNOME Shell started at ' + _startDate,
|
|
|
580c05 |
+ ['MESSAGE_ID=' + GNOMESHELL_STARTED_MESSAGE_ID]);
|
|
|
580c05 |
}
|
|
|
580c05 |
});
|
|
|
580c05 |
}
|
|
|
580c05 |
--
|
|
|
580c05 |
2.3.6
|
|
|
580c05 |
|