From 131d82cacd4600654d3e931287d2556f50bd9db5 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 18 Mar 2011 00:38:13 +0000 Subject: libglusterfs: added graph id in logging Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346 --- libglusterfs/src/glusterfs.h | 5 ++++- libglusterfs/src/graph.c | 2 ++ libglusterfs/src/logging.c | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index af03bd36b4f..f2fc64def17 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -306,6 +306,7 @@ struct _glusterfs_graph { void *first; void *top; /* selected by -n */ int xl_count; + int id; /* Used in logging */ uint32_t volfile_checksum; }; typedef struct _glusterfs_graph glusterfs_graph_t; @@ -332,7 +333,9 @@ struct _glusterfs_ctx { pthread_t sigwaiter; struct mem_pool *stub_mem_pool; unsigned char cleanup_started; - + int graph_id; /* Incremented per graph, value should + indicate how many times the graph has + got changed */ }; typedef struct _glusterfs_ctx glusterfs_ctx_t; diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index 5538df04d6d..990e96e2fd8 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -475,6 +475,8 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) fill_uuid (graph->graph_uuid, 128); + graph->id = ctx->graph_id++; + /* XXX: --xlator-option additions */ gf_add_cmdline_options (graph, &ctx->cmd_args); diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 2f598a6dc1a..c7f2561507b 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -395,10 +395,10 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function, else basename = file; - ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s %s: ", + ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s %d-%s: ", timestr, level_strings[level], basename, line, function, callstr, - domain); + ((this->graph) ? this->graph->id:0), domain); if (-1 == ret) { goto unlock; } @@ -534,10 +534,10 @@ log: else basename = file; - ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ", + ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %d-%s: ", timestr, level_strings[level], basename, line, function, - domain); + ((this->graph)?this->graph->id:0), domain); if (-1 == ret) { goto unlock; } -- cgit