X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftstlog.c;h=e93a22ef3b637878e4f9112e6fffc2b1dd4859df;hp=c41089b64707c772ae65b76a637c6763f635e5a8;hb=471c6dccdbb5c5a9c08b24c9abd6a1dcda29e79e;hpb=04e7f1b09e302ca5862d752e63e2a6e396c82047 diff --git a/test/tstlog.c b/test/tstlog.c index c41089b..e93a22e 100644 --- a/test/tstlog.c +++ b/test/tstlog.c @@ -2,13 +2,22 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tstlog.c,v 1.7 2005-09-09 10:20:14 adam Exp $ + * $Id: tstlog.c,v 1.10 2006-03-21 12:54:02 adam Exp $ * */ #include +#include #include #include #include +#if HAVE_UNISTD_H +#include +#endif + +void hook_func(int level, const char *msg, void *vp) +{ + fprintf(stderr, "[HOOK level=%d msg=%s]\n", level, msg); +} int main(int argc, char **argv) { @@ -16,8 +25,9 @@ int main(int argc, char **argv) int i, ret; int level = YLOG_LOG; int number = 1; + unsigned int wait_between_log = 0; - while ((ret = options("f:v:l:m:n:s:", argv, argc, &arg)) != -2) + while ((ret = options("f:v:l:m:n:s:w:Hh", argv, argc, &arg)) != -2) { switch (ret) { @@ -31,7 +41,10 @@ int main(int argc, char **argv) yaz_log_init_level(yaz_log_mask_str(arg)); break; case 'l': - yaz_log_init_file(arg); + if (!strcmp(arg, "@")) + yaz_log_init_file(0); + else + yaz_log_init_file(arg); break; case 'n': number = atoi(arg); @@ -39,14 +52,27 @@ int main(int argc, char **argv) case 'm': level = yaz_log_module_level(arg); break; + case 'w': + wait_between_log = atoi(arg); + break; + case 'H': + yaz_log_set_handler(hook_func, 0); + break; case 0: for (i = 0; i