aboutsummaryrefslogtreecommitdiff
path: root/src/helper/log.h
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-29 11:16:38 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-29 11:16:38 +0000
commit67e0aea25850b8286f750e6458e5de741e6cb3b5 (patch)
tree1225ab14f9cb5f79c12540b677a1d8aadcbce0bf /src/helper/log.h
parent4febcd8313cf46bea03bd5eacb3f287f19eb2961 (diff)
downloadriscv-openocd-67e0aea25850b8286f750e6458e5de741e6cb3b5.zip
riscv-openocd-67e0aea25850b8286f750e6458e5de741e6cb3b5.tar.gz
riscv-openocd-67e0aea25850b8286f750e6458e5de741e6cb3b5.tar.bz2
Summary: passing of variable argument list reduced, strings sent to logging are now formatted just once - more efficient.
As a result, ugly string malloc+strcpy are not needed anymore. git-svn-id: svn://svn.berlios.de/openocd/trunk@386 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper/log.h')
-rw-r--r--src/helper/log.h44
1 files changed, 14 insertions, 30 deletions
diff --git a/src/helper/log.h b/src/helper/log.h
index a53b7f5..c407844 100644
--- a/src/helper/log.h
+++ b/src/helper/log.h
@@ -47,7 +47,7 @@ enum log_levels
extern void log_printf(enum log_levels level, const char *file, int line,
const char *function, const char *format, ...)
__attribute__ ((format (printf, 5, 6)));
-extern void log_printfnl(enum log_levels level, const char *file, int line,
+extern void log_printf_lf(enum log_levels level, const char *file, int line,
const char *function, const char *format, ...)
__attribute__ ((format (printf, 5, 6)));
extern int log_register_commands(struct command_context_s *cmd_ctx);
@@ -55,13 +55,13 @@ extern int log_init(struct command_context_s *cmd_ctx);
extern int set_log_output(struct command_context_s *cmd_ctx, FILE *output);
typedef void (*log_callback_fn)(void *priv, const char *file, int line,
- const char *function, const char *format, va_list args);
+ const char *function, const char *string);
typedef struct log_callback_s
{
- log_callback_fn fn;
+ log_callback_fn fn;
void *priv;
- struct log_callback_s *next;
+ struct log_callback_s *next;
} log_callback_t;
extern int log_add_callback(log_callback_fn fn, void *priv);
@@ -76,44 +76,28 @@ extern int debug_level;
#define DEBUG(expr ...) \
- do { if (debug_level >= LOG_DEBUG) \
- log_printfnl (LOG_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf_lf (LOG_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr)
#define INFO(expr ...) \
- do { if (debug_level >= LOG_INFO) \
- log_printfnl (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf_lf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr)
-#define INFO_SAMELINE(expr ...) \
- do { if (debug_level >= LOG_INFO) \
- log_printf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+#define INFO_N(expr ...) \
+ log_printf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr)
#define WARNING(expr ...) \
- do { \
- log_printfnl (LOG_WARNING, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf_lf (LOG_WARNING, __FILE__, __LINE__, __FUNCTION__, expr)
#define ERROR(expr ...) \
- do { \
- log_printfnl (LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf_lf (LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, expr)
#define USER(expr ...) \
- do { \
- log_printfnl (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf_lf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr)
-#define USER_SAMELINE(expr ...) \
- do { \
- log_printf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+#define USER_N(expr ...) \
+ log_printf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr)
#define OUTPUT(expr ...) \
- do { \
- log_printf (LOG_OUTPUT, __FILE__, __LINE__, __FUNCTION__, expr); \
- } while(0)
+ log_printf (LOG_OUTPUT, __FILE__, __LINE__, __FUNCTION__, expr)
/* general failures