diff options
author | Colin Walters <walters@verbum.org> | 2013-01-15 21:50:42 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-01-15 21:50:42 -0500 |
commit | 0c232faa9d74a39358d75a098af25776a2e00529 (patch) | |
tree | f866efce79444ba265c31f283b1dc8e17e7ac739 | |
parent | 7229abafe3f8fac571cc1032dbfa16fce8954ade (diff) | |
download | libgsystem-0c232faa9d74a39358d75a098af25776a2e00529.tar.gz |
Revert "gsystemlog.la: New library which wraps sd_journal"
This reverts commit 7229abafe3f8fac571cc1032dbfa16fce8954ade.
After some discussion here:
https://bugzilla.gnome.org/show_bug.cgi?id=691785
and in person, Ray and I decided to not have a generic systemd/syslog
wrapper here.
-rw-r--r-- | Makefile-libgsystem.am | 19 | ||||
-rw-r--r-- | gsystem-log-syslog.c | 47 | ||||
-rw-r--r-- | gsystem-log-systemd.c | 104 | ||||
-rw-r--r-- | gsystem-log.h | 36 | ||||
-rw-r--r-- | libgsystem-testlog.c | 35 |
5 files changed, 0 insertions, 241 deletions
diff --git a/Makefile-libgsystem.am b/Makefile-libgsystem.am index 6110a33..adc997f 100644 --- a/Makefile-libgsystem.am +++ b/Makefile-libgsystem.am @@ -31,25 +31,6 @@ libgsystem_la_SOURCES = \ $(libgsystem_srcpath)/gsystem-subprocess.c \ $(libgsystem_srcpath)/libgsystem.h \ $(NULL) - libgsystem_la_CFLAGS = $(AM_CFLAGS) $(libgsystem_cflags) libgsystem_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^gs_" -no-undefined -export-dynamic libgsystem_la_LIBADD = $(libgsystem_libs) - -libgsystemlog_la_CFLAGS = $(libgsystem_la_CFLAGS) -libgsystemlog_la_LDFLAGS = $(libgsystem_la_LDFLAGS) -libgsystemlog_la_LIBADD = $(libgsystem_la_LIBADD) -libgsystemlog_la_SOURCES = $(libgsystem_srcpath)/gsystem-log.h -if HAVE_SYSTEMD_JOURNAL -libgsystemlog_la_SOURCES += $(libgsystem_srcpath)/gsystem-log-systemd.c -libgsystemlog_la_CFLAGS += $(SYSTEMD_JOURNAL_CFLAGS) -libgsystemlog_la_LIBADD += $(SYSTEMD_JOURNAL_LIBS) -else -libgsystemlog_la_SOURCES += $(libgsystem_srcpath)/gsystem-log-syslog.c -endif - -noinst_LTLIBRARIES += libgsystemlog.la -noinst_PROGRAMS += libgsystem-testlog -libgsystem_testlog_SOURCES = $(libgsystem_srcpath)/libgsystem-testlog.c -libgsystem_testlog_CFLAGS = $(libgsystem_la_CFLAGS) -libgsystem_testlog_LDADD = libgsystemlog.la $(libgsystem_libs) diff --git a/gsystem-log-syslog.c b/gsystem-log-syslog.c deleted file mode 100644 index 62a746e..0000000 --- a/gsystem-log-syslog.c +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2012 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> - -#include "gsystem-log.h" - -void -gs_slog_id (const gchar *message_id, - int priority, - const char *format, ...) -{ - va_list args; - char *msg; - - va_start (args, format); - msg = g_strdup_vprintf (format, args); - va_end (args); - - syslog (priority, "%s", msg); -} - -void -gs_log_error (GError *error) -{ - gs_slog_id (NULL, 4, "%s", error->message); -} - diff --git a/gsystem-log-systemd.c b/gsystem-log-systemd.c deleted file mode 100644 index 0e16dfe..0000000 --- a/gsystem-log-systemd.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2012 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> - -#include "gsystem-log.h" -/* No point including location since we wrap */ -#define SD_JOURNAL_SUPPRESS_LOCATION -#include <systemd/sd-journal.h> - -/** - * gs_slog_id: - * @message_id: An 128bit ID, formatted as a lowercase hexadecimal (32 bytes) - * @format: A format string - * - * Log a message with a unique ID. On systemd-based operating - * systems, this writes to the journal. The @message_id - * must follow the restrictions listed here: - * <ulink url="http://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html">. - */ -void -gs_slog_id (const char *message_id, - int priority, - const char *format, ...) -{ - va_list args; - const char *msgid_key = "MESSAGE_ID="; - const int msgid_keylen = strlen (msgid_key); - char msgid_buf[msgid_keylen + 32]; /* NOTE: Not NUL terminated */ - const char *priority_key = "PRIORITY="; - const int priority_keylen = strlen (priority_key); - char priority_buf[priority_keylen + 1]; /* NOTE: Not NUL terminated */ - struct iovec iov[3]; - char *raw_msg; - char *msg; - int n_iov = 0; - int res; - - g_return_if_fail (priority >= 0 && priority <= 7); - - va_start (args, format); - raw_msg = g_strdup_vprintf (format, args); - va_end (args); - - msg = g_strconcat ("MESSAGE=", raw_msg, NULL); - g_free (raw_msg); - - iov[n_iov].iov_base = msg; - iov[n_iov].iov_len = strlen (msg); - n_iov++; - memcpy (priority_buf, priority_key, priority_keylen); - *(priority_buf + priority_keylen) = 48 + priority; - iov[n_iov].iov_base = priority_buf; - iov[n_iov].iov_len = priority_keylen + 1; - n_iov++; - - if (message_id) - { - memcpy (msgid_buf, msgid_key, msgid_keylen); - g_assert (strlen (message_id) == 32); - memcpy (msgid_buf + msgid_keylen, message_id, 32); - - iov[n_iov].iov_base = msgid_buf; - iov[n_iov].iov_len = sizeof (msgid_buf); - n_iov++; - } - - res = sd_journal_sendv (iov, n_iov); - if (res != 0) - { - g_printerr ("sd_journal_send(): %s\n", g_strerror (-res)); - } - - g_free (msg); -} - -void -gs_log_error (GError *error) -{ - (void) sd_journal_send ("MESSAGE=%s", error->message, - "PRIORITY=%d", 4, /* LOG_ERR */ - "GERROR_DOMAIN=%d", error->domain, - "GERROR_CODE=%d", error->code, - NULL); -} diff --git a/gsystem-log.h b/gsystem-log.h deleted file mode 100644 index 302a4b7..0000000 --- a/gsystem-log.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2012 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. - */ - -#ifndef __GSYSTEM_LOG_H__ -#define __GSYSTEM_LOG_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -void gs_slog_id (const gchar *message_id, - int priority, - const char *format, ...) G_GNUC_PRINTF (3, 4); - -void gs_log_error (GError *error); - -G_END_DECLS - -#endif diff --git a/libgsystem-testlog.c b/libgsystem-testlog.c deleted file mode 100644 index 48f1704..0000000 --- a/libgsystem-testlog.c +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2012 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 "gsystem-log.h" - -int -main (int argc, - char **argv) -{ - gs_slog_id ("bc93e4eddc624cd889f21846a672d6e8", 3, - "hello %d %s ", 42, "world"); - gs_slog_id ("65bad39b7ef4426d9f4cd93c60ebfb9c", 5, - "moo %f cow", 3.14159); - return 0; -} |