summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2012-06-06 17:34:03 +0530
committerAnand Avati <avati@redhat.com>2012-08-01 12:06:11 -0700
commit3bf5cd69c6c8997b089ad9d007c72cfd92c7f44e (patch)
treeafe8767b63179a9f96d9928dc2a1d57a113a6673 /libglusterfs
parentd3a8a50a9da28cd12277ffac25767a790761d32f (diff)
event-history: implement gf_log_eh for saving events
Change-Id: I2ddf4e7849bda91bb99423e27082c2bae6800a70 BUG: 795419 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.com/3532 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/logging.c44
-rw-r--r--libglusterfs/src/logging.h9
2 files changed, 47 insertions, 6 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index c41d245f191..fc80f91d841 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -589,13 +589,49 @@ out:
}
int
-gf_log_eh (void *data)
+_gf_log_eh (const char *function, const char *fmt, ...)
{
- int ret = -1;
+ int ret = -1;
+ va_list ap;
+ char *str1 = NULL;
+ char *str2 = NULL;
+ char *msg = NULL;
+ xlator_t *this = NULL;
- ret = eh_save_history (THIS->history, data);
+ this = THIS;
- return ret;
+ ret = gf_asprintf (&str1, "[%d] %s: ",
+ ((this->graph)?this->graph->id:0),
+ function);
+ if (-1 == ret) {
+ goto out;
+ }
+
+ va_start (ap, fmt);
+
+ ret = vasprintf (&str2, fmt, ap);
+ if (-1 == ret) {
+ goto out;
+ }
+
+ va_end (ap);
+
+ msg = GF_MALLOC (strlen (str1) + strlen (str2) + 1, gf_common_mt_char);
+
+ strcpy (msg, str1);
+ strcat (msg, str2);
+
+ ret = eh_save_history (this->history, msg);
+
+out:
+ if (str1)
+ GF_FREE (str1);
+
+ /* Use FREE instead of GF_FREE since str2 was allocated by vasprintf */
+ if (str2)
+ FREE (str2);
+
+ return ret;
}
int
diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h
index bbf0d9a3891..0d290bd5a7a 100644
--- a/libglusterfs/src/logging.h
+++ b/libglusterfs/src/logging.h
@@ -73,6 +73,10 @@ extern char gf_log_xl_log_set;
levl, ##fmt); \
} while (0)
+#define gf_log_eh(fmt...) do { \
+ _gf_log_eh (__FUNTION__, ##fmt); \
+ } while (0)
+
#define gf_log_callingfn(dom, levl, fmt...) do { \
FMT_WARN (fmt); \
\
@@ -99,8 +103,7 @@ extern char gf_log_xl_log_set;
void gf_log_logrotate (int signum);
-int
-gf_log_eh (void *data);
+
void gf_log_globals_init (void);
int gf_log_init (const char *filename);
void gf_log_cleanup (void);
@@ -118,6 +121,8 @@ int _gf_log_nomem (const char *domain, const char *file,
const char *function, int line, gf_loglevel_t level,
size_t size);
+int _gf_log_eh (const char *function, const char *fmt, ...);
+
int gf_log_from_client (const char *msg, char *identifier);
void gf_log_lock (void);