X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=test%2Ftstlog.c;h=04f978713fcb824dd1f57f9ba4c402a600ce028b;hp=8bce12fc62d102767b6dbdc252c863b9855872a3;hb=69c2dee55aa204cab368989b8385eda8b83bf2e2;hpb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505 diff --git a/test/tstlog.c b/test/tstlog.c index 8bce12f..04f9787 100644 --- a/test/tstlog.c +++ b/test/tstlog.c @@ -1,44 +1,77 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2009 Index Data * See the file LICENSE for details. - * - * $Id: tstlog.c,v 1.5 2005-06-25 15:46:07 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) { char *arg; - int ret; + int i, ret; int level = YLOG_LOG; + int number = 1; + unsigned int wait_between_log = 0; - while ((ret = options("f:v:l:m:", argv, argc, &arg)) != -2) + while ((ret = options("f:p:v:l:m:n:r:w:Hh", argv, argc, &arg)) != -2) { switch (ret) { + 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); break; 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: - yaz_log(level, "%s", arg); + for (i = 0; i