Document more tstlog options
[yaz-moved-to-github.git] / test / tstlog.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: tstlog.c,v 1.7 2005-09-09 10:20:14 adam Exp $
6  *
7  */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <yaz/options.h>
11 #include <yaz/log.h>
12
13 int main(int argc, char **argv)
14 {
15     char *arg;
16     int i, ret;
17     int level = YLOG_LOG;
18     int number = 1;
19
20     while ((ret = options("f:v:l:m:n:s:", argv, argc, &arg)) != -2)
21     {
22         switch (ret)
23         {
24         case 's':
25             yaz_log_init_max_size(atoi(arg));
26             break;
27         case 'f':
28             yaz_log_time_format(arg);
29             break;
30         case 'v':
31             yaz_log_init_level(yaz_log_mask_str(arg));
32             break;
33         case 'l':
34             yaz_log_init_file(arg);
35             break;
36         case 'n':
37             number = atoi(arg);
38             break;
39         case 'm':        
40             level = yaz_log_module_level(arg);
41             break;
42         case 0:
43             for (i = 0; i<number; i++)
44                 yaz_log(level, "%d %s", i, arg);
45             break;
46         default:
47             fprintf(stderr, "tstlog. Bad option\n");
48             fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] "
49                     "[-m module] [-s max] [-n num] msg ..\n");
50             exit(1);
51         }
52     }
53     exit(0);
54 }
55 /*
56  * Local variables:
57  * c-basic-offset: 4
58  * indent-tabs-mode: nil
59  * End:
60  * vim: shiftwidth=4 tabstop=8 expandtab
61  */
62