summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.h
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-03-16 09:38:21 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-17 11:57:11 -0700
commitebe47d5dae42da18b289e7be44eb67a8157a56b1 (patch)
tree13d3c68f86ca5dec97f8a1ca183d801bc9d3c92b /libglusterfs/src/logging.h
parentce01662eefb575d1afe397486653920ec101f40f (diff)
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 <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2346 (Log message enhancements in GlusterFS - phase 1) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'libglusterfs/src/logging.h')
-rw-r--r--libglusterfs/src/logging.h39
1 files changed, 23 insertions, 16 deletions
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__ */