summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ea69d1d)
raw | patch | inline | side by side (parent: ea69d1d)
author | niki <niki> | |
Sat, 17 Dec 2005 02:35:20 +0000 (02:35 +0000) | ||
committer | niki <niki> | |
Sat, 17 Dec 2005 02:35:20 +0000 (02:35 +0000) |
src/utils_debug.c | patch | blob | history | |
src/utils_debug.h | patch | blob | history |
diff --git a/src/utils_debug.c b/src/utils_debug.c
index db59525e3f94a5497dd56597c98266ce54b52498..9a6c1c5eeb9471772cc0603e312e9232db000e75 100644 (file)
--- a/src/utils_debug.c
+++ b/src/utils_debug.c
#include "common.h"
#include "utils_debug.h"
-/* *** *** *** global variables *** *** *** */
#if COLLECT_DEBUG
-#define DEFAULT_FILENAME "collectd.log"
-
static void cu_vdebug(const char *file, int line, const char *func,
const char *format, va_list ap);
/* if preemptive threads are used, these vars need some sort of locking! */
-/* pth is non-preemptive, so no locking is necessary (?) */
+/* pth is non-preemptive, so no locking is necessary */
static FILE *cu_debug_file = NULL;
static char *cu_debug_filename = NULL;
int
cu_debug_startfile(const char *file, int line, const char *func,
- const char *format, ...)
+ const char *filename, const char *format, ...)
{
va_list ap;
}
if(cu_debug_filename == NULL) {
- cu_debug_filename = sstrdup(DEFAULT_FILENAME);
+ cu_debug_filename = sstrdup(filename);
}
cu_debug_file = fopen(cu_debug_filename, "a");
} /* int cu_debug_resetfile(const char *file, int line, const char *func,
const char *filename) */
-#else /* !COLLECT_DEBUG */
-
-void
-cu_debug(const char *file, int line, const char *func, const char *format, ...)
-{
-}
-int
-cu_debug_startfile(const char *file, int line, const char *func, const char *format, ...)
-{
- return EXIT_SUCCESS;
-}
-int
-cu_debug_stopfile(const char *file, int line, const char *func, const char *format, ...)
-{
- return EXIT_SUCCESS;
-}
-int
-cu_debug_resetfile(const char *file, int line, const char *func, const char *filename)
-{
- return EXIT_SUCCESS;
-}
-
#endif /* COLLECT_DEBUG */
diff --git a/src/utils_debug.h b/src/utils_debug.h
index 247b141d641955757d7a70ad9175273b3450432d..561e6b1ec87c84fbb8f5cac53113e8e385041573 100644 (file)
--- a/src/utils_debug.h
+++ b/src/utils_debug.h
* Niki W. Waibel <niki.waibel@gmx.net>
**/
+/* BUG: at the moment you can use DBG_STARTFILE only ONCE in
+ your program. more then one logfile is not supported. */
+
#if !COLLECTD_UTILS_DEBUG_H
#define COLLECTD_UTILS_DEBUG_H 1
+#if COLLECT_DEBUG
+
#define DBG(...) cu_debug(__FILE__, __LINE__, __func__, \
__VA_ARGS__)
-#define DBG_STARTFILE(...) cu_debug_startfile(__FILE__, __LINE__, \
- __func__, __VA_ARGS__)
+#define DBG_STARTFILE(file, ...) cu_debug_startfile(__FILE__, __LINE__, \
+ __func__, file, __VA_ARGS__)
#define DBG_STOPFILE(...) cu_debug_stopfile(__FILE__, __LINE__, \
__func__, __VA_ARGS__)
const char *format, ...);
int cu_debug_startfile(const char *file, int line, const char *func,
- const char *format, ...);
+ const char *filename, const char *format, ...);
int cu_debug_stopfile(const char *file, int line, const char *func,
const char *format, ...);
int cu_debug_resetfile(const char *file, int line, const char *func,
const char *filename);
+#else /* !COLLECT_DEBUG */
+
+#define DBG(...) /* DBG(...) */
+#define DBG_STARTFILE(file, ...) /* DBG_STARTFILE(file, ...) */
+#define DBG_STOPFILE(...) /* DBG_STOPFILE(...) */
+#define DBG_RESETFILE(file) /* DBG_RESETFILE(file) */
+
+#endif /* COLLECT_DEBUG */
+
#endif /* !COLLECTD_UTILS_DEBUG_H */