From 36197e32322202a7518d821aa7306cf24de77c39 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 3 Nov 2004 22:30:52 +0000 Subject: [PATCH] Added test program for logging. --- test/Makefile.am | 6 ++++-- test/tstlog.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 test/tstlog.c diff --git a/test/Makefile.am b/test/Makefile.am index 8528e8d..6ba430f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 index 0000000..3e6dbe2 --- /dev/null +++ b/test/tstlog.c @@ -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 +#include +#include +#include + +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); +} -- 1.7.10.4