[gnome-ostree-integration] gnome-continuous-journal-log-hack: New program
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree-integration] gnome-continuous-journal-log-hack: New program
- Date: Mon, 30 Sep 2013 13:56:18 +0000 (UTC)
commit 2ede1d675d0b71e113272caf3069af68a9afde22
Author: Colin Walters <walters verbum org>
Date: Sat Sep 21 16:50:23 2013 -0400
gnome-continuous-journal-log-hack: New program
I want to log to journald from platform-independent test script
injected from gnome-continuous. I don't want to write native testing
code since then I have to care about architecture which is annoying.
libgsystem of course has logging API but it's designed to be embedded
with your app, which is hard/annoying for injecting overlay binaries.
So...that leaves us with this hack, until we get structured logging in
GLib and unicorns for everyone.
.gitmodules | 3 +
Makefile-journal-log-hack.am | 28 ++++++++++++
Makefile.am | 1 +
autogen.sh | 8 +++
configure.ac | 32 ++++++++++++++
src/gnome-continuous-journal-log-hack/main.c | 60 ++++++++++++++++++++++++++
src/libgsystem | 1 +
7 files changed, 133 insertions(+), 0 deletions(-)
---
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f456a14
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/libgsystem"]
+ path = src/libgsystem
+ url = git://git.gnome.org/libgsystem
diff --git a/Makefile-journal-log-hack.am b/Makefile-journal-log-hack.am
new file mode 100644
index 0000000..12cf144
--- /dev/null
+++ b/Makefile-journal-log-hack.am
@@ -0,0 +1,28 @@
+# Copyright (C) 2013 Colin Walters <walters verbum org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+libgsystem_srcpath := src/libgsystem
+libgsystem_cflags = $(GIO_UNIX_CFLAGS) $(SYSTEMD_JOURNAL_CFLAGS) -I$(srcdir)/src/libgsystem
+libgsystem_libs = $(GIO_UNIX_LIBS) $(SYSTEMD_JOURNAL_LIBS)
+include src/libgsystem/Makefile-libgsystem.am
+noinst_LTLIBRARIES += libgsystem.la
+
+bin_PROGRAMS += gnome-continuous-journal-log-hack
+
+gnome_continuous_journal_log_hack_SOURCES = src/gnome-continuous-journal-log-hack/main.c
+gnome_continuous_journal_log_hack_CFLAGS = -I$(top_srcdir)/src/libgsystem $(GIO_UNIX_CFLAGS)
+gnome_continuous_journal_log_hack_LDADD = $(GIO_UNIX_LIBS) libgsystem.la
diff --git a/Makefile.am b/Makefile.am
index 67878a4..02f6e89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,6 +34,7 @@ privlibdir = $(pkglibdir)
privlib_LTLIBRARIES =
INSTALL_DATA_HOOKS =
+include Makefile-journal-log-hack.am
include Makefile-integration.am
include Makefile-installboot.am
diff --git a/autogen.sh b/autogen.sh
index 6035bc0..05cc82b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -14,6 +14,14 @@ fi
mkdir -p m4
+# Fetch submodules if needed
+if test ! -f src/libgsystem/README;
+then
+ echo "+ Setting up submodules"
+ git submodule init
+ git submodule update
+fi
+
autoreconf --force --install --verbose
cd $olddir
diff --git a/configure.ac b/configure.ac
index 223b6c2..07d03e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,12 +21,44 @@ AM_SILENT_RULES([yes])
AM_PATH_PYTHON([2.6])
PKG_PROG_PKG_CONFIG
+AC_PROG_CC
+AM_PROG_CC_C_O
+
+changequote(,)dnl
+if test "x$GCC" = "xyes"; then
+ WARN_CFLAGS="-Wall -Werror=strict-prototypes -Werror=missing-prototypes \
+ -Werror=implicit-function-declaration \
+ -Werror=pointer-arith -Werror=init-self -Werror=format=2 \
+ -Werror=format-security \
+ -Werror=missing-include-dirs -Werror=aggregate-return \
+ -Werror=declaration-after-statement"
+fi
+changequote([,])dnl
+AC_SUBST(WARN_CFLAGS)
+
+# Initialize libtool
+LT_PREREQ([2.2.4])
+LT_INIT([disable-static])
+
+PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0 >= 2.34.0])
+
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
[Directory for systemd service files]),
[with_systemdsystemunitdir=$withval], [with_systemdsystemunitdir=$($PKG_CONFIG
--variable=systemdsystemunitdir systemd)])
AC_SUBST(SYSTEMD_SYSTEM_UNIT_DIR, [$with_systemdsystemunitdir])
+AC_ARG_WITH(systemd-journal,
+ AS_HELP_STRING([--without-systemd-journal], [Use systemd @<:@default=auto@:>@]),
+ [], [with_systemd_journal=auto])
+AS_IF([test x$with_systemd_journal != xno], [
+ PKG_CHECK_MODULES([SYSTEMD_JOURNAL], [libsystemd-journal >= 200], have_systemd_journal=yes,
have_systemd_journal=no)
+ ])
+AM_CONDITIONAL(ENABLE_SYSTEMD_JOURNAL, test x$have_systemd_journal = xyes)
+AS_IF([test x$have_systemd_journal = xyes], [
+ AC_DEFINE([ENABLE_SYSTEMD_JOURNAL],[1],[Define if you want to build with systemd journal support])
+])
+
AC_CONFIG_FILES([
Makefile
])
diff --git a/src/gnome-continuous-journal-log-hack/main.c b/src/gnome-continuous-journal-log-hack/main.c
new file mode 100644
index 0000000..2c3905b
--- /dev/null
+++ b/src/gnome-continuous-journal-log-hack/main.c
@@ -0,0 +1,60 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2013 Colin Walters <walters verbum org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+/* This program exists to allow JS test scripts to log to journald.
+ * Until structured logging is added to GLib.
+ */
+#include "libgsystem.h"
+
+int
+main (int argc, char **argv)
+{
+ GError *local_error = NULL;
+ GError **error = &local_error;
+ gs_free char *msgid = NULL;
+ const char *eq;
+ const char *msg;
+
+ if (argc <= 1)
+ {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Usage: %s MESSAGEID=MESSAGE", argv[0]);
+ goto out;
+ }
+
+ msg = argv[1];
+ eq = strchr (msg, '=');
+ g_assert (eq);
+ msgid = g_strndup (msg, eq - msg);
+ gs_log_structured_print_id_v (msgid, "%s", eq + 1);
+
+ out:
+ if (local_error)
+ {
+ g_printerr ("%s\n", local_error->message);
+ g_clear_error (&local_error);
+ return 1;
+ }
+ return 0;
+}
diff --git a/src/libgsystem b/src/libgsystem
new file mode 160000
index 0000000..66140c0
--- /dev/null
+++ b/src/libgsystem
@@ -0,0 +1 @@
+Subproject commit 66140c018f044ba038ddb6bc1e6e97eb87d2b8f6
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]