* 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 $
*/
/**
/** 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);
* 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 $
*/
/**
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)
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)
* 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 <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <yaz/options.h>
#include <yaz/log.h>
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<number; i++)