summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2014-05-08 12:30:23 -0300
committerVijay Bellur <vbellur@redhat.com>2014-05-22 02:48:58 -0700
commitcec37c9b66b8711b213f114875d215f56b8120aa (patch)
tree3dc24701727ba90847d6b291e30d09d60a226f49
parent2e7ed9e196a04d19a78e2880af21b959ca1f578b (diff)
logging: remove unused message-id scripts
The current unused implementation for message-ids in the logs depends on automatically generated files. The generated files are not included in the distributed tarball. This causes issues when distributions build packages, they need to re-run ./autogen.sh to create the needed files. I thought of including the generated files in the distribution tarball. However, the contents of these files are not actively used, so it seems to make more sense to drop it all together. These functions were the only users of libintl and gettext too, so dropped the requirement checking from configure.ac. A replacement for the message-id logging framework is in progress. Any changes that this patch makes, can be reverted in the submission of patches for the new framework. Reference: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/6212 Change-Id: Iea82dd3910944a5c6be3ee393806eccabd575e11 BUG: 1038391 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/7714 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am3
-rwxr-xr-xautogen.sh19
-rw-r--r--configure.ac3
-rw-r--r--contrib/argp-standalone/configure.ac2
-rw-r--r--doc/logging.txt66
-rw-r--r--error-codes.json4
-rwxr-xr-xgen-headers.py59
-rw-r--r--gf-error-codes.h.template34
-rw-r--r--libglusterfs/src/Makefile.am2
-rw-r--r--libglusterfs/src/logging.c64
11 files changed, 12 insertions, 245 deletions
diff --git a/.gitignore b/.gitignore
index 7e8e11c..bb19429 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,7 +52,6 @@ libgfchangelog.pc
libglusterfs/src/graph.lex.c
libglusterfs/src/y.tab.c
libglusterfs/src/y.tab.h
-libglusterfs/src/gf-error-codes.h
libtool
run-tests.sh
xlators/mount/fuse/utils/mount.glusterfs
diff --git a/Makefile.am b/Makefile.am
index 41859a2..0331c86 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,8 +2,7 @@ EXTRA_DIST = autogen.sh \
COPYING-GPLV2 COPYING-LGPLV3 \
INSTALL README AUTHORS THANKS NEWS \
glusterfs.spec glusterfs-api.pc.in libgfchangelog.pc.in \
- error-codes.json gf-error-codes.h.template \
- gen-headers.py run-tests.sh \
+ run-tests.sh \
build-aux/pkg-version \
build-aux/xdrgen \
contrib/argp-standalone \
diff --git a/autogen.sh b/autogen.sh
index eb869d5..fef2f03 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -60,15 +60,6 @@ if [ $? -ne 0 ]; then
MISSING="$MISSING tar"
fi
-# Check for python
-if [ "x${PYTHONBIN}" = "x" ]; then
- PYTHONBIN=python
-fi
-env ${PYTHONBIN} -V > /dev/null 2>&1
-if [ $? -ne 0 ]; then
- MISSING="$MISSING python"
-fi
-
## If dependencies are missing, warn the user and abort
if [ "x$MISSING" != "x" ]; then
echo "Aborting."
@@ -84,16 +75,6 @@ if [ "x$MISSING" != "x" ]; then
exit 1
fi
-## generate gf-error-codes.h from error-codes.json
-echo "Generate gf-error-codes.h ..."
-if ${PYTHONBIN} ./gen-headers.py; then
- if ! mv -fv gf-error-codes.h libglusterfs/src/gf-error-codes.h; then
- exit 1
- fi
-else
- exit 1
-fi
-
## Do the autogeneration
echo Running ${ACLOCAL}...
$ACLOCAL -I ./contrib/aclocal
diff --git a/configure.ac b/configure.ac
index aa55fdb..39bea64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -312,7 +312,6 @@ AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads libr
AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))
AC_CHECK_LIB([readline], [rl_do_undo], [RL_UNDO="yes"], [RL_UNDO="no"])
-AC_CHECK_LIB([intl], [gettext])
AC_CHECK_HEADERS([sys/xattr.h])
@@ -324,8 +323,6 @@ AC_CHECK_HEADERS([openssl/md5.h])
AC_CHECK_HEADERS([linux/falloc.h])
-AC_CHECK_HEADERS([libintl.h])
-
dnl Mac OS X does not have spinlocks
AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
if test "x${have_spinlock}" = "xyes"; then
diff --git a/contrib/argp-standalone/configure.ac b/contrib/argp-standalone/configure.ac
index 167b234..98bedc6 100644
--- a/contrib/argp-standalone/configure.ac
+++ b/contrib/argp-standalone/configure.ac
@@ -32,7 +32,7 @@ fi
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(limits.h malloc.h unistd.h sysexits.h stdarg.h)
+AC_CHECK_HEADERS(libintl.h limits.h malloc.h unistd.h sysexits.h stdarg.h)
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
diff --git a/doc/logging.txt b/doc/logging.txt
deleted file mode 100644
index b4ee459..0000000
--- a/doc/logging.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-
-New logging framework in glusterfs is targeted for end users like
-customers, community members, testers etc. This aims to bring clear,
-understandable logs called user logs whereas the current logging are
-considered as developer logs. The new framework brings with following
-features
-
-* Each message is logged with proper well defined error code and each
- error code has well known error message.
-* A logbook has defined error code and error messages. It helps to
- keep track of possible causes and remedies
-* Log are sent to syslog. The syslog application can be configured to
- pass them to centralized logging system
-* It brings
- - Remove repeated log messages
- - Send alerts to users on certain events
- - Run a program on events
- - Call home service on events
-
-
-Log book:
-=========
-A log book is a JSON formatted file error-codes.json located in top
-level of glusterfs source repository. At compile time, gen-headers.py
-generates libglusterfs/src/gf-error-codes.h using the log book and
-gf-error-codes.h.template file. libglusterfs/src/gf-error-codes.h
-consists of header definitions and helper functions to get message by
-code for given locale. Currently it has _gf_get_message() function
-returns message for locale 'en'.
-
-New entry to log book is added like
-
-{
- "IO_ERROR": {"code": 2233,
- "message": {"en": "I/O error occurred"}},
- "SETUP_ERROR": {"code": 2240,
- "message": {"en": "Setup error"}},
-}
-
-
-Logging:
-========
-The framework provides two functions
-
-void gf_openlog (const char *ident, int option, int facility);
-void gf_syslog (int error_code, int facility_priority, char *format, ...);
-
-Consumers need to call gf_openlog() prior to gf_syslog() like the way
-traditional syslog function calls. error_code is mandatory when using
-gf_syslog(). For example,
-
-gf_openlog (NULL, -1, -1);
-gf_syslog (GF_ERR_DEV, LOG_ERR, "error reading configuration file");
-
-The logs are sent in CEE format (http://cee.mitre.org/) to syslog.
-Its targeted to rsyslog syslog server.
-
-This log framework is enabled at compile time by default. This can be
-disabled by passing '--disable-syslog' to ./configure or '--without
-syslog' to rpmbuild
-
-Even though its enabled at compile time, its required to have
-/etc/glusterfs/logger.conf file to make it into effect before starting
-gluster services
-
-Currently all gluster logs are sent with error code GF_ERR_DEV.
diff --git a/error-codes.json b/error-codes.json
deleted file mode 100644
index 5121049..0000000
--- a/error-codes.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "ERR_DEV": {"code": 9999,
- "message": {"en": "devel error"}}
-}
diff --git a/gen-headers.py b/gen-headers.py
deleted file mode 100755
index 6e40580..0000000
--- a/gen-headers.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-
-import sys
-try:
- import json
-except ImportError:
- import simplejson as json
-from string import Template
-
-
-def getLogBook(logFile='error-codes.json'):
- fp = open(logFile)
- return json.load(fp)
-
-
-def genCHeader(logBook,
- infile='gf-error-codes.h.template',
- outfile='gf-error-codes.h'):
- fp = open('gf-error-codes.h.template')
- s = fp.read()
- fp.close()
- template = Template(s)
-
- defineLines = []
- caseLines = []
- for name, value in logBook.iteritems():
- nameDef = "GF_%s" % (name.upper(),)
- code = value['code']
- msgNameDef = "%s_MSG" % (nameDef,)
- msg = value['message']['en']
-
- defineLines.append("#define %-20s %d" % (nameDef, code))
- defineLines.append("#define %-20s %s" % (msgNameDef,
- json.dumps(msg)))
- caseLines.append("#ifdef HAVE_LIBINTL_H")
- caseLines.append(" case %s: return _(%s);" % \
- (nameDef, msgNameDef))
- caseLines.append("#else")
- caseLines.append(" case %s: return %s;" % \
- (nameDef, msgNameDef))
- caseLines.append("#endif")
-
- d = {'DEFINES': "\n".join(defineLines),
- 'CASES': "\n".join(caseLines)}
- #print template.substitute(d)
-
- fp = open(outfile, 'w')
- fp.write(template.substitute(d))
- fp.close()
-
-
-if __name__ == "__main__":
- try:
- logBook = getLogBook()
- genCHeader(logBook)
- sys.exit(0)
- except IOError, e:
- print str(e)
- sys.exit(-1)
diff --git a/gf-error-codes.h.template b/gf-error-codes.h.template
deleted file mode 100644
index 5ca64fd..0000000
--- a/gf-error-codes.h.template
+++ /dev/null
@@ -1,34 +0,0 @@
-/***************************************************************/
-/** **/
-/** DO NOT EDIT THIS FILE **/
-/** THIS IS AUTO-GENERATED FROM LOG BOOK **/
-/** YOUR CHANGES WILL BE LOST IN NEXT BUILD **/
-/** **/
-/***************************************************************/
-
-#ifndef _GF_ERROR_CODES_H
-#define _GF_ERROR_CODES_H
-
-#ifdef HAVE_LIBINTL_H
-#include <libintl.h>
-
-#define _(STRING) gettext(STRING)
-#endif
-
-/** START: ERROR CODE DEFINITIONS **/
-$DEFINES
-/** END: ERROR CODE DEFINITIONS **/
-
-
-/** START: FUNCTION RETURNS MESSAGE OF GIVEN ERROR CODE **/
-const char *
-_gf_get_message (int code) {
- switch (code) {
-$CASES
- default: return NULL;
- }
-}
-/** END: FUNCTION RETURNS MESSAGE OF GIVEN ERROR CODE **/
-
-
-#endif
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index 569d69b..ccac1a1 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -29,7 +29,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
$(CONTRIBDIR)/stdlib/gf_mkostemp.c strfd.c \
$(CONTRIBDIR)/mount/mntent.c
-nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c gf-error-codes.h
+nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c
BUILT_SOURCES = graph.lex.c
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 2a8335e..505580d 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -23,16 +23,11 @@
#include <stdlib.h>
#include <syslog.h>
-#ifdef HAVE_LIBINTL_H
-#include <libintl.h>
-#endif
-
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
#include <sys/stat.h>
-#include "gf-error-codes.h"
#define GF_JSON_MSG_LENGTH 8192
#define GF_SYSLOG_CEE_FORMAT \
@@ -477,18 +472,6 @@ gf_log_fini (void *data)
return ret;
}
-/**
- * gf_get_error_message -function to get error message for given error code
- * @error_code: error code defined by log book
- *
- * @return: success: string
- * failure: NULL
- */
-const char *
-gf_get_error_message (int error_code) {
- return _gf_get_message (error_code);
-}
-
/**
* gf_openlog -function to open syslog specific to gluster based on
@@ -516,10 +499,6 @@ gf_openlog (const char *ident, int option, int facility)
/* TODO: Should check for errors here and return appropriately */
setlocale(LC_ALL, "");
-#ifdef HAVE_LIBINTL_H
- bindtextdomain("gluster", "/usr/share/locale");
- textdomain("gluster");
-#endif
/* close the previous syslog if open as we are changing settings */
closelog ();
openlog(ident, _option, _facility);
@@ -633,50 +612,28 @@ _json_escape(const char *str, char *buf, size_t len)
/**
* gf_syslog -function to submit message to syslog specific to gluster
- * @error_code: error code defined by log book
* @facility_priority: facility_priority of syslog()
* @format: optional format string to syslog()
*
* @return: void
*/
void
-gf_syslog (int error_code, int facility_priority, char *format, ...)
+gf_syslog (int facility_priority, char *format, ...)
{
char *msg = NULL;
char json_msg[GF_JSON_MSG_LENGTH];
GF_UNUSED char *p = NULL;
- const char *error_message = NULL;
- char json_error_message[GF_JSON_MSG_LENGTH];
va_list ap;
- error_message = gf_get_error_message (error_code);
+ GF_ASSERT (format);
va_start (ap, format);
- if (format) {
- vasprintf (&msg, format, ap);
+ if (vasprintf (&msg, format, ap) != -1) {
p = _json_escape (msg, json_msg, GF_JSON_MSG_LENGTH);
- if (error_message) {
- p = _json_escape (error_message, json_error_message,
- GF_JSON_MSG_LENGTH);
- syslog (facility_priority, GF_SYSLOG_CEE_FORMAT,
- json_msg, error_code, json_error_message);
- } else {
- /* ignore the error code because no error message for it
- and use normal syslog */
- syslog (facility_priority, "%s", msg);
- }
+ syslog (facility_priority, "%s", msg);
free (msg);
- } else {
- if (error_message) {
- /* no user message: treat error_message as msg */
- syslog (facility_priority, GF_SYSLOG_CEE_FORMAT,
- json_error_message, error_code,
- json_error_message);
- } else {
- /* cannot produce log as neither error_message nor
- msg available */
- }
- }
+ } else
+ syslog (GF_LOG_CRITICAL, "vasprintf() failed, out of memory?");
va_end (ap);
}
@@ -898,8 +855,7 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
vasprintf (&str2, fmt, ap);
va_end (ap);
- gf_syslog (GF_ERR_DEV, priority,
- "[%s:%d:%s] %s %d-%s: %s",
+ gf_syslog (priority, "[%s:%d:%s] %s %d-%s: %s",
basename, line, function,
callstr,
((this->graph) ? this->graph->id:0), domain,
@@ -1376,8 +1332,7 @@ gf_log_syslog (glusterfs_ctx_t *ctx, const char *domain, const char *file,
break;
case gf_logformat_cee:
/* TODO: Enhance CEE with additional parameters */
- gf_syslog (GF_ERR_DEV, priority,
- "[%s:%d:%s] %d-%s: %s",
+ gf_syslog (priority, "[%s:%d:%s] %d-%s: %s",
file, line, function, graph_id, domain, *appmsgstr);
break;
@@ -2180,8 +2135,7 @@ _gf_log (const char *domain, const char *file, const char *function, int line,
vasprintf (&str2, fmt, ap);
va_end (ap);
- gf_syslog (GF_ERR_DEV, priority,
- "[%s:%d:%s] %d-%s: %s",
+ gf_syslog (priority, "[%s:%d:%s] %d-%s: %s",
basename, line, function,
((this->graph) ? this->graph->id:0), domain, str2);
goto err;