X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftstlog.c;h=2fcacafc82dc1d0bd9c00944cb23677d0d589c4d;hb=e6f45fddb3d4267340ad320dbedfbf5cb68c4d21;hp=f61070f2897feb9b98f8db7e6d7a3504dadc0622;hpb=d061373561c647edbc7125796b53ab0c789d6648;p=yaz-moved-to-github.git diff --git a/test/tstlog.c b/test/tstlog.c index f61070f..2fcacaf 100644 --- a/test/tstlog.c +++ b/test/tstlog.c @@ -1,14 +1,23 @@ /* - * Copyright (C) 1995-2005, Index Data ApS + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: tstlog.c,v 1.6 2005-09-08 13:22:58 adam Exp $ + * $Id: tstlog.c,v 1.14 2007-06-05 06:40:28 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,22 +25,29 @@ 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:p:v:l:m:n:r:w:Hh", argv, argc, &arg)) != -2) { switch (ret) { - case 's': + case 'r': yaz_log_init_max_size(atoi(arg)); break; case 'f': yaz_log_time_format(arg); break; + case 'p': + yaz_log_init_prefix(arg); + break; case 'v': 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 +55,26 @@ 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