From: Adam Dickmeiss Date: Tue, 21 Mar 2006 12:54:02 +0000 (+0000) Subject: Remove log_event_{start,end}. Add function yaz_log_set_handler instead X-Git-Tag: YAZ.2.1.16~24 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=41b946725f2c8d8617b3e4ece161cb9d99bfaa5c Remove log_event_{start,end}. Add function yaz_log_set_handler instead --- diff --git a/include/yaz/log.h b/include/yaz/log.h index 418aef3..7f1b04b 100644 --- a/include/yaz/log.h +++ b/include/yaz/log.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: log.h,v 1.34 2005-06-25 15:46:02 adam Exp $ + * $Id: log.h,v 1.35 2006-03-21 12:54:02 adam Exp $ */ /** @@ -131,10 +131,9 @@ YAZ_EXPORT int yaz_log_module_level(const char *name); /** yaz_log_file returns the file handle for yaz_log. */ YAZ_EXPORT FILE *yaz_log_file(void); -YAZ_EXPORT void log_event_start(void (*func)(int level, const char *msg, void *info), - void *info); -YAZ_EXPORT void log_event_end(void (*func)(int level, const char *msg, void *info), - void *info); +/** yza_log_set_handler allows log output to be captured to something else */ +YAZ_EXPORT void yaz_log_set_handler(void (*func)(int, const char *, + void *), void *info); YAZ_EXPORT void yaz_log_reopen(void); diff --git a/src/log.c b/src/log.c index 0bb27e7..e9fcea4 100644 --- a/src/log.c +++ b/src/log.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: log.c,v 1.31 2006-03-21 12:31:48 adam Exp $ + * $Id: log.c,v 1.32 2006-03-21 12:54:02 adam Exp $ */ /** @@ -247,21 +247,13 @@ void yaz_log_init_max_size(int mx) l_max_size = mx; } -static void (*start_hook_func)(int, const char *, void *) = NULL; -static void *start_hook_info; -static void (*end_hook_func)(int, const char *, void *) = NULL; -static void *end_hook_info; +static void (*hook_func)(int, const char *, void *) = NULL; +static void *hook_info; -void log_event_start(void (*func)(int, const char *, void *), void *info) +void yaz_log_set_handler(void (*func)(int, const char *, void *), void *info) { - start_hook_func = func; - start_hook_info = info; -} - -void log_event_end(void (*func)(int, const char *, void *), void *info) -{ - end_hook_func = func; - end_hook_info = info; + hook_func = func; + hook_info = info; } static void yaz_log_open_check(struct tm *tm, int force) @@ -400,14 +392,12 @@ void yaz_log(int level, const char *fmt, ...) strcat(buf, "]"); } va_end (ap); - if (start_hook_func) - (*start_hook_func)(o_level, buf, start_hook_info); + if (hook_func) + (*hook_func)(o_level, buf, hook_info); file = yaz_log_file(); if (file) yaz_log_to_file(level, file, buf); - if (end_hook_func) - (*end_hook_func)(o_level, buf, end_hook_info); } void yaz_log_time_format(const char *fmt) diff --git a/test/tstlog.c b/test/tstlog.c index dcb87d3..e93a22e 100644 --- a/test/tstlog.c +++ b/test/tstlog.c @@ -2,10 +2,11 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstlog.c,v 1.9 2006-03-21 12:32:16 adam Exp $ + * $Id: tstlog.c,v 1.10 2006-03-21 12:54:02 adam Exp $ * */ #include +#include #include #include #include @@ -55,7 +56,7 @@ int main(int argc, char **argv) wait_between_log = atoi(arg); break; case 'H': - log_event_start(hook_func, 0); + yaz_log_set_handler(hook_func, 0); break; case 0: for (i = 0; i