Moved back to a single log.h, with the new #define YAZ_USE_NEW_LOG
[yaz-moved-to-github.git] / test / tstlog.c
1 /*
2  * Copyright (c) 2004, Index Data
3  * See the file LICENSE for details.
4  *
5  * $Id: tstlog.c,v 1.3 2004-12-13 14:21:58 heikki 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 ret;
17     int level = YLOG_LOG;
18
19     while ((ret = options("f:v:l:m:", argv, argc, &arg)) != -2)
20     {
21         switch (ret)
22         {
23         case 'f':
24             yaz_log_time_format(arg);
25             break;
26         case 'v':
27             yaz_log_init_level(yaz_log_mask_str(arg));
28             break;
29         case 'l':
30             yaz_log_init_file(arg);
31             break;
32         case 'm':        
33             level = yaz_log_module_level(arg);
34             break;
35         case 0:
36             yaz_log(level, "%s", arg);
37             break;
38         default:
39             fprintf(stderr, "tstlog. Bad option\n");
40             fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] "
41                     "[-m module] msg ..\n");
42             exit(1);
43         }
44     }
45     exit(0);
46 }