From ebe47d5dae42da18b289e7be44eb67a8157a56b1 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 16 Mar 2011 09:38:21 +0000 Subject: libglusterfs: gf_log_nomem() and other minor updates log will be done when the memory allocation fails, hence in code, no explicit logs required for memory allocation failures. also, if there are logs before actually doing a log_init(), they will be logged in 'stderr'. 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/logging.h | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'libglusterfs/src/logging.h') diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index aa6e00edb..0664b2efa 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -69,8 +69,6 @@ typedef enum { GF_LOG_TRACE, /* full trace of operation */ } gf_loglevel_t; -#define GF_LOG_MAX GF_LOG_DEBUG - extern gf_loglevel_t gf_log_loglevel; extern char gf_log_xl_log_set; @@ -94,27 +92,38 @@ extern char gf_log_xl_log_set; levl, ##fmt); \ } while (0) + +/* No malloc or calloc should be called in this function */ +#define gf_log_nomem(dom, levl, size) do { \ + if ((levl > gf_log_loglevel) && !gf_log_xl_log_set) \ + break; \ + _gf_log_nomem (dom, __FILE__, __FUNCTION__, __LINE__, \ + levl, size); \ + } while (0) + + /* Log once in GF_UNIVERSAL_ANSWER times */ #define GF_LOG_OCCASIONALLY(var, args...) if (!(var++%GF_UNIVERSAL_ANSWER)) { \ gf_log (args); \ } -void -gf_log_logrotate (int signum); +void gf_log_logrotate (int signum); +void gf_log_globals_init (void); int gf_log_init (const char *filename); void gf_log_cleanup (void); -int -_gf_log (const char *domain, const char *file, const char *function, - int32_t line, gf_loglevel_t level, const char *fmt, ...); -int -_gf_log_callingfn (const char *domain, const char *file, const char *function, - int32_t line, gf_loglevel_t level, const char *fmt, ...); +int _gf_log (const char *domain, const char *file, const char *function, + int32_t line, gf_loglevel_t level, const char *fmt, ...); +int _gf_log_callingfn (const char *domain, const char *file, const char *function, + int32_t line, gf_loglevel_t level, const char *fmt, ...); + +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_from_client (const char *msg, char *identifier); +int gf_log_from_client (const char *msg, char *identifier); void gf_log_lock (void); void gf_log_unlock (void); @@ -135,9 +144,7 @@ void gf_log_set_xl_loglevel (void *xl, gf_loglevel_t level); #define GF_ERROR(xl, format, args...) \ gf_log ((xl)->name, GF_LOG_ERROR, format, ##args) -int -gf_cmd_log (const char *domain, const char *fmt, ...); +int gf_cmd_log (const char *domain, const char *fmt, ...); -int -gf_cmd_log_init (const char *filename); +int gf_cmd_log_init (const char *filename); #endif /* __LOGGING_H__ */ -- cgit