summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2014-05-22 16:35:48 +0200
committerNiels de Vos <ndevos@redhat.com>2014-05-24 08:26:08 -0700
commitd74024b470fdd0e1d0b14aeb7e914d4d64aa2a24 (patch)
tree32df18b6aecf37cda4d4d8af878b69970668fa2f
parentcebc9cafa2ee8d4ccfa459dcddb00c6388d7bd86 (diff)
logging: remove unused message-id scriptsv3.5.1beta
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. Cherry picked from commit cec37c9b66b8711b213f114875d215f56b8120aa: > 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> Change-Id: Iea82dd3910944a5c6be3ee393806eccabd575e11 BUG: 1089054 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/7851 Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r--Makefile.am3
-rw-r--r--argp-standalone/configure.ac2
-rwxr-xr-xautogen.sh19
-rw-r--r--configure.ac2
-rw-r--r--doc/logging.txt66
-rw-r--r--error-codes.json4
-rwxr-xr-xgen-headers.py54
-rw-r--r--gf-error-codes.h.template33
-rw-r--r--libglusterfs/src/Makefile.am2
-rw-r--r--libglusterfs/src/logging.c61
10 files changed, 12 insertions, 234 deletions
diff --git a/Makefile.am b/Makefile.am
index 19f21fc..0b65c68 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 \
$(shell find $(top_srcdir)/tests -type f -print)
SUBDIRS = argp-standalone libglusterfs rpc api xlators glusterfsd \
diff --git a/argp-standalone/configure.ac b/argp-standalone/configure.ac
index 2ecd2a8..8a892fc 100644
--- a/argp-standalone/configure.ac
+++ b/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/autogen.sh b/autogen.sh
index cd8603b..e870855 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 37998e6..06bd7a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,8 +262,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_FUNC([gettext], [has_gettext=yes], AC_CHECK_LIB([intl], [gettext], , AC_MSG_ERROR([gettext support is required to build glusterfs])))
-
AC_CHECK_HEADERS([sys/xattr.h])
AC_CHECK_HEADERS([sys/extattr.h])
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 ef9fa77..0000000
--- a/gen-headers.py
+++ /dev/null
@@ -1,54 +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(" case %s: return _(%s);" % \
- (nameDef, msgNameDef))
-
- 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 ab6020d..0000000
--- a/gf-error-codes.h.template
+++ /dev/null
@@ -1,33 +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
-
-#include <libintl.h>
-
-#define _(STRING) gettext(STRING)
-
-
-/** 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 907399a..e7cbcbe 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -28,7 +28,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
$(CONTRIBDIR)/stdlib/gf_mkostemp.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 0058233..4a905a2 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -23,14 +23,10 @@
#include <stdlib.h>
#ifdef GF_USE_SYSLOG
-#include <libintl.h>
#include <syslog.h>
#include <sys/stat.h>
-#include "gf-error-codes.h"
#define GF_JSON_MSG_LENGTH 8192
-#define GF_SYSLOG_CEE_FORMAT \
- "@cee: {\"msg\": \"%s\", \"gf_code\": \"%u\", \"gf_message\": \"%s\"}"
#define GF_LOG_CONTROL_FILE "/etc/glusterfs/logger.conf"
#endif /* GF_USE_SYSLOG */
@@ -148,18 +144,6 @@ gf_log_fini (void *data)
}
#ifdef GF_USE_SYSLOG
-/**
- * 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
@@ -186,8 +170,6 @@ gf_openlog (const char *ident, int option, int facility)
}
setlocale(LC_ALL, "");
- bindtextdomain("gluster", "/usr/share/locale");
- textdomain("gluster");
openlog(ident, _option, _facility);
}
@@ -300,50 +282,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);
}
#endif /* GF_USE_SYSLOG */
@@ -528,8 +488,7 @@ _gf_log_nomem (const char *domain, const char *file,
} else {
priority = level - 1;
}
- gf_syslog (GF_ERR_DEV, priority,
- "[%s:%d:%s] %s %s: no memory "
+ gf_syslog (priority, "[%s:%d:%s] %s %s: no memory "
"available for size (%"GF_PRI_SIZET")",
basename, line, function, callstr, domain,
size);
@@ -668,8 +627,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,
@@ -805,8 +763,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;