summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c61
1 files changed, 9 insertions, 52 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 0058233a7cf..4a905a24def 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;