Added test program for logging.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Nov 2004 22:30:52 +0000 (22:30 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 3 Nov 2004 22:30:52 +0000 (22:30 +0000)
test/Makefile.am
test/tstlog.c [new file with mode: 0644]

index 8528e8d..6ba430f 100644 (file)
@@ -1,8 +1,8 @@
 ## Copyright (C) 1994-2004, Index Data
 ## All rights reserved.
-## $Id: Makefile.am,v 1.3 2004-10-01 11:43:43 adam Exp $
+## $Id: Makefile.am,v 1.4 2004-11-03 22:30:52 adam Exp $
 
-check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl
+check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog
 check_SCRIPTS = tstcql.sh tstmarc.sh
 
 TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
@@ -39,3 +39,5 @@ tstodr_SOURCES = tstodrcodec.c tstodrcodec.h tstodr.c
 
 tstccl_SOURCES = tstccl.c
 
+tstlog_SOURCES = tstlog.c
+
diff --git a/test/tstlog.c b/test/tstlog.c
new file mode 100644 (file)
index 0000000..3e6dbe2
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2004, Index Data
+ * See the file LICENSE for details.
+ *
+ * $Id: tstlog.c,v 1.1 2004-11-03 22:30:52 adam Exp $
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <yaz/options.h>
+#include <yaz/log.h>
+
+int main(int argc, char **argv)
+{
+    char *arg;
+    int ret;
+    int level = LOG_LOG;
+
+    while ((ret = options("f:v:l:m:", argv, argc, &arg)) != -2)
+    {
+       switch (ret)
+       {
+       case 'f':
+           yaz_log_time_format(arg);
+           break;
+       case 'v':
+           yaz_log_init_level(yaz_log_mask_str(arg));
+           break;
+       case 'l':
+           yaz_log_init_file(arg);
+           break;
+       case 'm':        
+           level = yaz_log_module_level(arg);
+           break;
+       case 0:
+           yaz_log(level, "%s", arg);
+           break;
+       default:
+           fprintf(stderr, "tstlog. Bad option\n");
+           fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] "
+                   "[-m module] msg ..\n");
+           exit(1);
+       }
+    }
+    exit(0);
+}