Updated code to use new YAZ log functions/defines.
[idzebra-moved-to-github.git] / index / zebraapi.c
index eebf263..2351bc4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebraapi.c,v 1.120.2.16 2006-10-12 13:05:59 adam Exp $
+/* $Id: zebraapi.c,v 1.120.2.20 2006-12-05 21:14:40 adam Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -53,11 +53,11 @@ static void zebra_chdir (ZebraService zs)
 {
     const char *dir ;
     ASSERTZS;
-    yaz_log(LOG_API,"zebra_chdir");
+    yaz_log(YLOG_DEBUG, "zebra_chdir");
     dir = res_get (zs->global_res, "chdir");
     if (!dir)
        return;
-    logf (LOG_DEBUG, "chdir %s", dir);
+    yaz_log(YLOG_DEBUG, "chdir %s", dir);
 #ifdef WIN32
     _chdir(dir);
 #else
@@ -68,7 +68,7 @@ static void zebra_chdir (ZebraService zs)
 static void zebra_flush_reg (ZebraHandle zh)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_flush_reg");
+    yaz_log(YLOG_DEBUG, "zebra_flush_reg");
     zh->errCode=0;
     zebraExplain_flush (zh->reg->zei, zh);
     
@@ -93,7 +93,7 @@ ZebraHandle zebra_open (ZebraService zs)
         return 0;
 
     zh = (ZebraHandle) xmalloc (sizeof(*zh));
-    yaz_log (LOG_DEBUG, "zebra_open zs=%p returns %p", zs, zh);
+    yaz_log(YLOG_DEBUG, "zebra_open zs=%p returns %p", zs, zh);
 
     zh->service = zs;
     zh->reg = 0;          /* no register attached yet */
@@ -123,12 +123,12 @@ ZebraHandle zebra_open (ZebraService zs)
     zh->iconv_to_utf8 =
         yaz_iconv_open ("UTF-8", default_encoding);
     if (zh->iconv_to_utf8 == 0)
-        yaz_log (LOG_WARN, "iconv: %s to UTF-8 unsupported",
+        yaz_log(YLOG_WARN, "iconv: %s to UTF-8 unsupported",
            default_encoding);
     zh->iconv_from_utf8 =
         yaz_iconv_open (default_encoding, "UTF-8");
     if (zh->iconv_to_utf8 == 0)
-        yaz_log (LOG_WARN, "iconv: UTF-8 to %s unsupported",
+        yaz_log(YLOG_WARN, "iconv: UTF-8 to %s unsupported",
            default_encoding);
 
     zebra_mutex_cond_lock (&zs->session_lock);
@@ -150,7 +150,9 @@ ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
 {
     Res res;
 
-    yaz_log(LOG_LOG,"zebra_start %s %s", configName, ZEBRAVER);
+    yaz_log(YLOG_LOG, "zebra_start %s %s", configName, ZEBRAVER);
+
+    zebra_flock_init();
 
     if ((res = res_open (configName, def_res, over_res)))
     {
@@ -158,7 +160,7 @@ ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
        const char *passwd_encrypt = 0;
         ZebraService zh = xmalloc (sizeof(*zh));
 
-       yaz_log (LOG_DEBUG, "Read resources `%s'", configName);
+       yaz_log(YLOG_DEBUG, "Read resources `%s'", configName);
         
         zh->global_res = res;
         zh->configName = xstrdup(configName);
@@ -176,13 +178,13 @@ ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
         {
             zh->passwd_db = passwd_db_open();
             if (!zh->passwd_db)
-                logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed");
+                yaz_log(YLOG_WARN|YLOG_ERRNO, "passwd_db_open failed");
             else
            {
                if (passwd_plain)
                    if (passwd_db_file_plain(zh->passwd_db, passwd_plain))
                    {
-                       logf(LOG_WARN, 
+                       yaz_log(YLOG_WARN, 
                             "Failed to read passwords %s (or unsupported)",
                             passwd_plain);
                    }
@@ -190,7 +192,7 @@ ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
                {
                    if (passwd_db_file_crypt(zh->passwd_db, passwd_encrypt))
                    {
-                       logf(LOG_WARN, 
+                       yaz_log(YLOG_WARN, 
                             "Failed to read encrypted pwds %s "
                             "(or unsupported)", passwd_encrypt);
                    }
@@ -234,7 +236,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
 
     assert (res);
 
-    yaz_log (LOG_LOG|LOG_API, "zebra_register_open rw = %d useshadow=%d p=%p,n=%s,rp=%s",
+    yaz_log(YLOG_LOG|YLOG_DEBUG, "zebra_register_open rw = %d useshadow=%d p=%p,n=%s,rp=%s",
              rw, useshadow, reg, name, reg_path ? reg_path : "(none)");
     
     reg->dh = data1_createx (DATA1_FLAG_XML);
@@ -251,7 +253,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
 
     getcwd(cwd, sizeof(cwd)-1);
     profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);
-    yaz_log(LOG_LOG, "profilePath=%s cwd=%s", profilePath, cwd);
+    yaz_log(YLOG_LOG, "profilePath=%s cwd=%s", profilePath, cwd);
 
     data1_set_tabpath (reg->dh, profilePath);
     data1_set_tabroot (reg->dh, reg_path);
@@ -294,7 +296,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
 
     if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
     {
-       logf (LOG_WARN, "rec_open");
+       yaz_log(YLOG_WARN, "rec_open");
        return 0;
     }
     if (rw)
@@ -303,12 +305,12 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
     }
     if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
     {
-       logf (LOG_WARN, "dict_open");
+       yaz_log(YLOG_WARN, "dict_open");
        return 0;
     }
     if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
     {
-       logf (LOG_WARN, "sortIdx_open");
+       yaz_log(YLOG_WARN, "sortIdx_open");
        return 0;
     }
     if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
@@ -317,7 +319,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isams = isams_open (reg->bfs, FNAME_ISAMS, rw,
                                      key_isams_m(res, &isams_m))))
        {
-           logf (LOG_WARN, "isams_open");
+           yaz_log(YLOG_WARN, "isams_open");
            return 0;
        }
     }
@@ -326,7 +328,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
                                  sizeof (struct it_key), res)))
        {
-           logf (LOG_WARN, "is_open");
+           yaz_log(YLOG_WARN, "is_open");
            return 0;
        }
     }
@@ -336,7 +338,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
                                    rw, key_isamc_m(res, &isamc_m))))
        {
-           logf (LOG_WARN, "isc_open");
+           yaz_log(YLOG_WARN, "isc_open");
            return 0;
        }
     }
@@ -347,7 +349,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
                                      rw, key_isamd_m(res, &isamd_m))))
        {
-           logf (LOG_WARN, "isamd_open");
+           yaz_log(YLOG_WARN, "isamd_open");
            return 0;
        }
     }
@@ -358,7 +360,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
                                        rw, key_isamc_m(res, &isamc_m), 0)))
        {
-           logf (LOG_WARN, "isamb_open");
+           yaz_log(YLOG_WARN, "isamb_open");
            return 0;
        }
     }
@@ -369,7 +371,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
                                        rw, key_isamc_m(res, &isamc_m), 1)))
        {
-           logf (LOG_WARN, "isamb_open");
+           yaz_log(YLOG_WARN, "isamb_open");
            return 0;
        }
     }
@@ -380,7 +382,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
        if (!(reg->isamb = isamb_open (reg->bfs, "isamb",
                                        rw, key_isamc_m(res, &isamc_m), -1)))
        {
-           logf (LOG_WARN, "isamb_open");
+           yaz_log(YLOG_WARN, "isamb_open");
            return 0;
        }
     }
@@ -389,18 +391,18 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
                                   explain_extract);
     if (!reg->zei)
     {
-       logf (LOG_WARN, "Cannot obtain EXPLAIN information");
+       yaz_log(YLOG_WARN, "Cannot obtain EXPLAIN information");
        return 0;
     }
     reg->active = 2;
-    yaz_log (LOG_DEBUG, "zebra_register_open ok p=%p", reg);
+    yaz_log(YLOG_DEBUG, "zebra_register_open ok p=%p", reg);
     return reg;
 }
 
 int zebra_admin_shutdown (ZebraHandle zh)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_shutdown");
+    yaz_log(YLOG_DEBUG, "zebra_admin_shutdown");
     zh->errCode=0;
 
     zebra_mutex_cond_lock (&zh->service->session_lock);
@@ -413,7 +415,7 @@ int zebra_admin_start (ZebraHandle zh)
 {
     ZebraService zs;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_start");
+    yaz_log(YLOG_DEBUG, "zebra_admin_start");
     zh->errCode=0;
     zs = zh->service;
     zebra_mutex_cond_lock (&zs->session_lock);
@@ -424,7 +426,7 @@ int zebra_admin_start (ZebraHandle zh)
 static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
 {
     ASSERTZS;
-    yaz_log(LOG_LOG|LOG_API, "zebra_register_close p=%p", reg);
+    yaz_log(YLOG_LOG|YLOG_DEBUG, "zebra_register_close p=%p", reg);
     reg->stop_flag = 0;
     zebra_chdir (zs);
     if (reg->records)
@@ -465,7 +467,7 @@ int zebra_stop(ZebraService zs)
 {
     if (!zs)
         return 0;
-    yaz_log (LOG_LOG|LOG_API, "zebra_stop");
+    yaz_log(YLOG_LOG|YLOG_DEBUG, "zebra_stop");
 
     while (zs->sessions)
     {
@@ -489,14 +491,14 @@ int zebra_close (ZebraHandle zh)
     struct zebra_session **sp;
     int i;
 
-    yaz_log(LOG_API,"zebra_close");
+    yaz_log(YLOG_DEBUG, "zebra_close");
     if (!zh)
         return 0;
     ASSERTZH;
     zh->errCode=0;
     
     zs = zh->service;
-    yaz_log (LOG_DEBUG, "zebra_close zh=%p", zh);
+    yaz_log(YLOG_DEBUG, "zebra_close zh=%p", zh);
     resultSetDestroy (zh, -1, 0, 0);
 
     if (zh->reg)
@@ -567,7 +569,7 @@ static Res zebra_open_res (ZebraHandle zh)
     }
     else
     {
-        yaz_log (LOG_WARN, "no register root specified");
+        yaz_log(YLOG_WARN, "no register root specified");
         return 0;  /* no path for register - fail! */
     }
     return res;
@@ -699,7 +701,7 @@ void map_basenames (ZebraHandle zh, ODR stream,
     struct map_baseinfo *p = &info;
     int i;
     ASSERTZH;
-    yaz_log(LOG_API,"map_basenames ");
+    yaz_log(YLOG_DEBUG, "map_basenames ");
     zh->errCode=0;
 
     info.zh = zh;
@@ -722,7 +724,7 @@ void map_basenames (ZebraHandle zh, ODR stream,
     *num_bases = info.new_num_bases;
     *basenames = info.new_basenames;
     for (i = 0; i<*num_bases; i++)
-       logf (LOG_LOG, "base %s", (*basenames)[i]);
+       yaz_log(YLOG_LOG, "base %s", (*basenames)[i]);
 }
 
 int zebra_select_default_database(ZebraHandle zh)
@@ -743,7 +745,7 @@ int zebra_select_default_database(ZebraHandle zh)
 int zebra_select_database (ZebraHandle zh, const char *basename)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_select_database %s",basename);
+    yaz_log(YLOG_DEBUG, "zebra_select_database %s",basename);
     return zebra_select_databases (zh, 1, &basename);
 }
 
@@ -755,7 +757,7 @@ int zebra_select_databases (ZebraHandle zh, int num_bases,
     int len = 0;
     char *new_reg = 0;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_select_databases n=%d [0]=%s",
+    yaz_log(YLOG_DEBUG, "zebra_select_databases n=%d [0]=%s",
                    num_bases,basenames[0]);
     zebra_clearError(zh);
     
@@ -830,7 +832,7 @@ int zebra_search_RPN (ZebraHandle zh, ODR o,
                       Z_RPNQuery *query, const char *setname, int *hits)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_search_rpn");
+    yaz_log(YLOG_DEBUG, "zebra_search_rpn");
 
     zebra_clearError(zh);
     zh->hits = 0;
@@ -858,7 +860,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream,
     ZebraPosSet poset;
     int i, *pos_array, ret = 0;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_records_retrieve n=%d",num_recs);
+    yaz_log(YLOG_DEBUG, "zebra_records_retrieve n=%d",num_recs);
 
     zebra_clearError(zh);
 
@@ -878,7 +880,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream,
     poset = zebraPosSetCreate (zh, setname, num_recs, pos_array);
     if (!poset)
     {
-        logf (LOG_DEBUG, "zebraPosSetCreate error");
+        yaz_log(YLOG_DEBUG, "zebraPosSetCreate error");
         zh->errCode = 30;
         zh->errString = nmem_strdup (stream->mem, setname);
        ret = -1;
@@ -929,7 +931,7 @@ int zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
                 int *is_partial)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_scan");
+    yaz_log(YLOG_DEBUG, "zebra_scan");
     zh->errCode=0;
     if (zebra_begin_read (zh))
     {
@@ -950,7 +952,7 @@ int zebra_sort (ZebraHandle zh, ODR stream,
                 int *sort_status)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_sort");
+    yaz_log(YLOG_DEBUG, "zebra_sort");
     zh->errCode=0;
     if (zebra_begin_read (zh))
        return 1;
@@ -966,7 +968,7 @@ int zebra_deleleResultSet(ZebraHandle zh, int function,
 {
     int i, status;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_deleleResultSet n=%d",num_setnames);
+    yaz_log(YLOG_DEBUG, "zebra_deleleResultSet n=%d",num_setnames);
     zh->errCode=0;
     if (zebra_begin_read(zh))
        return Z_DeleteStatus_systemProblemAtTarget;
@@ -991,10 +993,10 @@ int zebra_errCode (ZebraHandle zh)
 {
     if (zh)
     {
-        yaz_log(LOG_API,"zebra_errCode: %d",zh->errCode);
+        yaz_log(YLOG_DEBUG, "zebra_errCode: %d",zh->errCode);
         return zh->errCode;
     }
-    yaz_log(LOG_API,"zebra_errCode: o");
+    yaz_log(YLOG_DEBUG, "zebra_errCode: o");
     return 0; 
 }
 
@@ -1003,7 +1005,7 @@ const char *zebra_errString (ZebraHandle zh)
     const char *e="";
     if (zh)
         e= diagbib1_str (zh->errCode);
-    yaz_log(LOG_API,"zebra_errString: %s",e);
+    yaz_log(YLOG_DEBUG, "zebra_errString: %s",e);
     return e;
 }
 
@@ -1012,7 +1014,7 @@ char *zebra_errAdd (ZebraHandle zh)
     char *a="";
     if (zh)
         a= zh->errString;
-    yaz_log(LOG_API,"zebra_errAdd: %s",a);
+    yaz_log(YLOG_DEBUG, "zebra_errAdd: %s",a);
     return a;
 }
 
@@ -1040,7 +1042,7 @@ int zebra_auth (ZebraHandle zh, const char *user, const char *pass)
     xfree (zh->user_perm);
     zh->user_perm = xstrdup(p ? p : "r");
 
-    yaz_log(LOG_LOG, "User perm for %s: %s", u, zh->user_perm);
+    yaz_log(YLOG_LOG, "User perm for %s: %s", u, zh->user_perm);
 
     /* users that don't require a password .. */
     if (zh->user_perm && strchr(zh->user_perm, 'a'))
@@ -1055,7 +1057,7 @@ int zebra_admin_import_begin (ZebraHandle zh, const char *database,
                                const char *record_type)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_import_begin db=%s rt=%s", 
+    yaz_log(YLOG_DEBUG, "zebra_admin_import_begin db=%s rt=%s", 
                     database, record_type);
     zh->errCode=0;
     if (zebra_select_database(zh, database))
@@ -1068,7 +1070,7 @@ int zebra_admin_import_begin (ZebraHandle zh, const char *database,
 int zebra_admin_import_end (ZebraHandle zh)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_import_end");
+    yaz_log(YLOG_DEBUG, "zebra_admin_import_end");
     zh->errCode=0;
     zebra_end_trans (zh);
     return 0;
@@ -1079,7 +1081,7 @@ int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
     int sysno;
     int i;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_import_segment");
+    yaz_log(YLOG_DEBUG, "zebra_admin_import_segment");
     zh->errCode=0;
     for (i = 0; i<segment->num_segmentRecords; i++)
     {
@@ -1102,7 +1104,7 @@ int zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
                                    &sysno,
                                    0, /* match */
                                    0, /* fname */
-                                   oct->buf, oct->len,
+                                   (char *) oct->buf, oct->len,
                                    0);
            }
        }
@@ -1124,7 +1126,7 @@ int zebra_admin_exchange_record (ZebraHandle zh,
     char *rinfo = 0;
     char recid_z[256];
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_admin_exchange_record ac=%d", action);
+    yaz_log(YLOG_DEBUG, "zebra_admin_exchange_record ac=%d", action);
     zh->errCode=0;
 
     if (!recid_buf || recid_len <= 0 || recid_len >= sizeof(recid_z))
@@ -1209,7 +1211,7 @@ int zebra_drop_database (ZebraHandle zh, const char *database)
 {
     int ret = 0;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_drop_database");
+    yaz_log(YLOG_DEBUG, "zebra_drop_database");
 
     zebra_clearError(zh);
 
@@ -1226,7 +1228,7 @@ int zebra_drop_database (ZebraHandle zh, const char *database)
     }
     else
     {
-       yaz_log(LOG_WARN, "drop database only supported for isam:b");
+       yaz_log(YLOG_WARN, "drop database only supported for isam:b");
        ret = -1;
     }
     zebra_end_trans (zh);
@@ -1236,7 +1238,7 @@ int zebra_drop_database (ZebraHandle zh, const char *database)
 int zebra_create_database (ZebraHandle zh, const char *database)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_create_database");
+    yaz_log(YLOG_DEBUG, "zebra_create_database");
     zh->errCode=0;
 
     if (zebra_select_database (zh, database))
@@ -1263,7 +1265,7 @@ int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
 {
     WRBUF wrbuf;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_string_norm ");
+    yaz_log(YLOG_DEBUG, "zebra_string_norm ");
     zh->errCode=0;
     if (!zh->reg->zebra_maps)
        return -1;
@@ -1287,14 +1289,14 @@ int zebra_set_state (ZebraHandle zh, int val, int seqno)
     long p = getpid();
     FILE *f;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_set_state v=%d seq=%d", val, seqno);
+    yaz_log(YLOG_DEBUG, "zebra_set_state v=%d seq=%d", val, seqno);
     zh->errCode=0;
 
     sprintf (state_fname, "state.%s.LCK", zh->reg_name);
     fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
     f = fopen (fname, "w");
 
-    yaz_log (LOG_DEBUG, "%c %d %ld", val, seqno, p);
+    yaz_log(YLOG_DEBUG, "%c %d %ld", val, seqno, p);
     fprintf (f, "%c %d %ld\n", val, seqno, p);
     fclose (f);
     xfree (fname);
@@ -1308,7 +1310,7 @@ int zebra_get_state (ZebraHandle zh, char *val, int *seqno)
     FILE *f;
 
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_get_state ");
+    yaz_log(YLOG_DEBUG, "zebra_get_state ");
     zh->errCode=0;
     sprintf (state_fname, "state.%s.LCK", zh->reg_name);
     fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
@@ -1373,7 +1375,7 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
         return -1;
     }
     ASSERTZHRES;
-    yaz_log(LOG_API,"zebra_begin_trans rw=%d",rw);
+    yaz_log(YLOG_DEBUG, "zebra_begin_trans rw=%d",rw);
 
     if (zh->user_perm)
     {
@@ -1442,7 +1444,7 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
             zebra_get_state (zh, &val, &seqno);
             if (val == 'c')
             {
-                yaz_log (LOG_LOG, "previous transaction didn't finish commit");
+                yaz_log(YLOG_LOG, "previous transaction didn't finish commit");
                 zebra_unlock (zh->lock_shadow);
                 zebra_unlock (zh->lock_normal);
                 zebra_commit (zh);
@@ -1454,20 +1456,20 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
                 {
                     BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
                                              zh->path_reg);
-                    yaz_log (LOG_LOG, "previous transaction didn't reach commit");
+                    yaz_log(YLOG_LOG, "previous transaction didn't reach commit");
                     bf_commitClean (bfs, rval);
                     bfs_destroy (bfs);
             }
                 else
                 {
-                    yaz_log (LOG_WARN, "your previous transaction didn't finish");
+                    yaz_log(YLOG_WARN, "your previous transaction didn't finish");
                 }
             }
             break;
         }
         if (pass == 2)
         {
-            yaz_log (LOG_FATAL, "zebra_begin_trans couldn't finish commit");
+            yaz_log(YLOG_FATAL, "zebra_begin_trans couldn't finish commit");
             abort();
             return -1;
         }
@@ -1490,7 +1492,7 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
 
             zh->errCode = 2;
             zh->errString = "zebra_begin_trans: cannot open register";
-            yaz_log(LOG_FATAL, zh->errString);
+            yaz_log(YLOG_FATAL, zh->errString);
             return -1;
         }
     }
@@ -1531,13 +1533,13 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
             dirty = 1;
         else if (seqno != zh->reg->seqno)
         {
-            yaz_log (LOG_LOG, "reopen seqno cur/old %d/%d",
+            yaz_log(YLOG_LOG, "reopen seqno cur/old %d/%d",
                      seqno, zh->reg->seqno);
             dirty = 1;
         }
         else if (zh->reg->last_val != val)
         {
-            yaz_log (LOG_LOG, "reopen last cur/old %d/%d",
+            yaz_log(YLOG_LOG, "reopen last cur/old %d/%d",
                      val, zh->reg->last_val);
             dirty = 1;
         }
@@ -1575,7 +1577,7 @@ int zebra_begin_trans (ZebraHandle zh, int rw)
 int zebra_end_trans (ZebraHandle zh)
 {
     ZebraTransactionStatus dummy;
-    yaz_log(LOG_API,"zebra_end_trans");
+    yaz_log(YLOG_DEBUG, "zebra_end_trans");
     return zebra_end_transaction(zh, &dummy);
 }
 
@@ -1586,7 +1588,7 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
     const char *rval;
 
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_end_transaction");
+    yaz_log(YLOG_DEBUG, "zebra_end_transaction");
 
     status->processed = 0;
     status->inserted  = 0;
@@ -1617,7 +1619,7 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
         zh->trans_no--;
         zh->trans_w_no = 0;
         
-        yaz_log (LOG_LOG, "zebra_end_trans");
+        yaz_log(YLOG_LOG, "zebra_end_trans");
         rval = res_get (zh->res, "shadow");
         
         zebraExplain_runNumberIncrement (zh->reg->zei, 1);
@@ -1629,7 +1631,7 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
         zebra_register_close (zh->service, zh->reg);
         zh->reg = 0;
         
-        yaz_log (LOG_LOG, "Records: %7d i/u/d %d/%d/%d", 
+        yaz_log(YLOG_LOG, "Records: %7d i/u/d %d/%d/%d", 
                  zh->records_processed, zh->records_inserted,
                  zh->records_updated, zh->records_deleted);
         
@@ -1642,7 +1644,7 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
         if (val != 'd')
         {
             BFiles bfs = bfs_create (rval, zh->path_reg);
-            yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
+            yaz_log(YLOG_LOG, "deleting shadow stuff val=%c", val);
             bf_commitClean (bfs, rval);
             bfs_destroy (bfs);
         }
@@ -1656,7 +1658,7 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status)
     }
 #if HAVE_SYS_TIMES_H
     times (&zh->tms2);
-    logf (LOG_LOG, "user/system: %ld/%ld",
+    yaz_log(YLOG_LOG, "user/system: %ld/%ld",
           (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
           (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
     
@@ -1670,7 +1672,6 @@ int zebra_repository_update (ZebraHandle zh, const char *path)
 {
     ASSERTZH;
     zh->errCode=0;
-    logf (LOG_LOG|LOG_API, "updating %s", path);
     repositoryUpdate (zh, path);
     return zh->errCode;
 }
@@ -1679,7 +1680,6 @@ int zebra_repository_delete (ZebraHandle zh, const char *path)
 {
     ASSERTZH;
     zh->errCode=0;
-    logf (LOG_LOG|LOG_API, "deleting %s", path);
     repositoryDelete (zh, path);
     return zh->errCode;
 }
@@ -1687,7 +1687,6 @@ int zebra_repository_delete (ZebraHandle zh, const char *path)
 int zebra_repository_show (ZebraHandle zh, const char *path)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_repository_show");
     zh->errCode=0;
     repositoryShow (zh, path);
     return zh->errCode;
@@ -1711,8 +1710,8 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
     rval = res_get (zh->res, "shadow");    
     if (!rval)
     {
-        logf (LOG_WARN, "Cannot perform commit");
-        logf (LOG_WARN, "No shadow area defined");
+        yaz_log(YLOG_WARN, "Cannot perform commit");
+        yaz_log(YLOG_WARN, "No shadow area defined");
         return 0;
     }
 
@@ -1725,7 +1724,7 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
 
     if (val == 'd')
     {
-        logf(LOG_WARN, "previous transaction didn't reach commit");
+        yaz_log(YLOG_WARN, "previous transaction didn't reach commit");
         clean_only = 1;
     }
 
@@ -1739,7 +1738,7 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
         {
             zebra_set_state (zh, 'c', seqno);
             
-            logf (LOG_LOG, "commit start");
+            yaz_log(YLOG_LOG, "commit start");
             bf_commitExec (bfs);
         }
         seqno++;
@@ -1756,7 +1755,7 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
     {
        zebra_unlock (zh->lock_shadow);
        zebra_unlock (zh->lock_normal);
-        logf (LOG_LOG, "nothing to commit");
+        yaz_log(YLOG_LOG, "nothing to commit");
     }
     bfs_destroy (bfs);
 
@@ -1765,13 +1764,13 @@ static int zebra_commit_ex (ZebraHandle zh, int clean_only)
 
 int zebra_clean (ZebraHandle zh)
 {
-    yaz_log(LOG_API,"zebra_clean");
+    yaz_log(YLOG_DEBUG, "zebra_clean");
     return zebra_commit_ex(zh, 1);
 }
 
 int zebra_commit (ZebraHandle zh)
 {
-    yaz_log(LOG_API,"zebra_commit");
+    yaz_log(YLOG_DEBUG, "zebra_commit");
     return zebra_commit_ex(zh, 0);
 }
 
@@ -1780,7 +1779,7 @@ int zebra_init (ZebraHandle zh)
     const char *rval;
     BFiles bfs = 0;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_init");
+    yaz_log(YLOG_DEBUG, "zebra_init");
     zh->errCode=0;
 
     zebra_select_default_database(zh);
@@ -1807,7 +1806,7 @@ int zebra_compact (ZebraHandle zh)
 {
     BFiles bfs;
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_compact");
+    yaz_log(YLOG_DEBUG, "zebra_compact");
     zh->errCode=0;
     if (!zh->res)
     {
@@ -1823,7 +1822,7 @@ int zebra_compact (ZebraHandle zh)
 int zebra_result (ZebraHandle zh, int *code, char **addinfo)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_result");
+    yaz_log(YLOG_DEBUG, "zebra_result");
     *code = zh->errCode;
     *addinfo = zh->errString;
     return 0;
@@ -1832,7 +1831,7 @@ int zebra_result (ZebraHandle zh, int *code, char **addinfo)
 int zebra_shadow_enable (ZebraHandle zh, int value)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_shadow_enable");
+    yaz_log(YLOG_DEBUG, "zebra_shadow_enable");
     zh->errCode=0;
     zh->shadow_enable = value;
     return 0;
@@ -1841,7 +1840,7 @@ int zebra_shadow_enable (ZebraHandle zh, int value)
 int zebra_record_encoding (ZebraHandle zh, const char *encoding)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_record_encoding");
+    yaz_log(YLOG_DEBUG, "zebra_record_encoding");
     zh->errCode=0;
     xfree (zh->record_encoding);
 
@@ -1857,16 +1856,16 @@ int zebra_record_encoding (ZebraHandle zh, const char *encoding)
     
     zh->record_encoding = xstrdup (encoding);
     
-    logf(LOG_DEBUG, "Reset record encoding: %s", encoding);
+    yaz_log(YLOG_DEBUG, "Reset record encoding: %s", encoding);
     
     zh->iconv_to_utf8 =
         yaz_iconv_open ("UTF-8", encoding);
     if (zh->iconv_to_utf8 == 0)
-        yaz_log (LOG_WARN, "iconv: %s to UTF-8 unsupported", encoding);
+        yaz_log(YLOG_WARN, "iconv: %s to UTF-8 unsupported", encoding);
     zh->iconv_from_utf8 =
         yaz_iconv_open (encoding, "UTF-8");
     if (zh->iconv_to_utf8 == 0)
-        yaz_log (LOG_WARN, "iconv: UTF-8 to %s unsupported", encoding);
+        yaz_log(YLOG_WARN, "iconv: UTF-8 to %s unsupported", encoding);
 
     return 0;
 }
@@ -1874,7 +1873,7 @@ int zebra_record_encoding (ZebraHandle zh, const char *encoding)
 int zebra_set_resource(ZebraHandle zh, const char *name, const char *value)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_set_resource %s:%s",name,value);
+    yaz_log(YLOG_DEBUG, "zebra_set_resource %s:%s",name,value);
     zh->errCode=0;
     res_set(zh->res, name, value);
     return 0;
@@ -1887,7 +1886,7 @@ const char *zebra_get_resource(ZebraHandle zh,
     ASSERTZH;
     v= res_get_def( zh->res, name, (char *)defaultvalue);
     zh->errCode=0;
-    yaz_log(LOG_API,"zebra_get_resource %s:%s",name,v);
+    yaz_log(YLOG_DEBUG, "zebra_get_resource %s:%s",name,v);
     return v;
 }
 
@@ -1897,19 +1896,19 @@ const char *zebra_get_resource(ZebraHandle zh,
 int zebra_trans_no (ZebraHandle zh)
 {
     ASSERTZH;
-    yaz_log(LOG_API,"zebra_trans_no");
+    yaz_log(YLOG_DEBUG, "zebra_trans_no");
     return zh->trans_no;
 }
 
 int zebra_get_shadow_enable (ZebraHandle zh)
 {
-    yaz_log(LOG_API,"zebra_get_shadow_enable");
+    yaz_log(YLOG_DEBUG, "zebra_get_shadow_enable");
     return (zh->shadow_enable);
 }
 
 int zebra_set_shadow_enable (ZebraHandle zh, int value)
 {
-    yaz_log(LOG_API,"zebra_set_shadow_enable %d",value);
+    yaz_log(YLOG_DEBUG, "zebra_set_shadow_enable %d",value);
     zh->shadow_enable = value;
     return 0;
 }
@@ -1923,7 +1922,7 @@ void api_records_retrieve (ZebraHandle zh, ODR stream,
 {
     ZebraPosSet poset;
     int i, *pos_array;
-    yaz_log(LOG_API,"api_records_retrieve s=%s n=%d",setname,num_recs);
+    yaz_log(YLOG_DEBUG, "api_records_retrieve s=%s n=%d",setname,num_recs);
 
     if (!zh->res)
     {
@@ -1943,7 +1942,7 @@ void api_records_retrieve (ZebraHandle zh, ODR stream,
     poset = zebraPosSetCreate (zh, setname, num_recs, pos_array);
     if (!poset)
     {
-        logf (LOG_DEBUG, "zebraPosSetCreate error");
+        yaz_log(YLOG_DEBUG, "zebraPosSetCreate error");
         zh->errCode = 30;
         zh->errString = nmem_strdup (stream->mem, setname);
     }
@@ -2019,7 +2018,7 @@ int zebra_insert_record (ZebraHandle zh,
                         const char *buf, int buf_size, int force_update)
 {
     int res;
-    yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno);
+    yaz_log(YLOG_DEBUG, "zebra_insert_record sysno=%d", *sysno);
 
     if (buf_size < 1) buf_size = strlen(buf);
 
@@ -2045,7 +2044,7 @@ int zebra_update_record (ZebraHandle zh,
 {
     int res;
 
-    yaz_log(LOG_API,"zebra_update_record sysno=%d", *sysno);
+    yaz_log(YLOG_DEBUG, "zebra_update_record sysno=%d", *sysno);
 
     if (buf_size < 1) buf_size = strlen(buf);
 
@@ -2059,7 +2058,7 @@ int zebra_update_record (ZebraHandle zh,
                                 match, fname,
                                 force_update, 
                                 1); /* allow_update */
-    yaz_log(LOG_LOG, "zebra_update_record returned res=%d", res);
+    yaz_log(YLOG_LOG, "zebra_update_record returned res=%d", res);
     zebra_end_trans(zh); 
     return res; 
 }
@@ -2071,7 +2070,7 @@ int zebra_delete_record (ZebraHandle zh,
                         int force_update) 
 {
     int res;
-    yaz_log(LOG_API,"zebra_delete_record sysno=%d", *sysno);
+    yaz_log(YLOG_DEBUG, "zebra_delete_record sysno=%d", *sysno);
 
     if (buf_size < 1) buf_size = strlen(buf);
 
@@ -2101,18 +2100,18 @@ int zebra_search_PQF (ZebraHandle zh, const char *pqf_query,
     Z_RPNQuery *query;
     ODR odr = odr_createmem(ODR_ENCODE);
 
-    yaz_log(LOG_API,"zebra_search_PQF s=%s q=%s",setname, pqf_query);
+    yaz_log(YLOG_DEBUG, "zebra_search_PQF s=%s q=%s",setname, pqf_query);
     
     query = p_query_rpn (odr, PROTO_Z3950, pqf_query);
     
     if (!query)
-        yaz_log (LOG_WARN, "bad query %s\n", pqf_query);
+        yaz_log(YLOG_WARN, "bad query %s\n", pqf_query);
     else
         res=zebra_search_RPN (zh, odr, query, setname, &hits);
     
     odr_destroy(odr);
 
-    yaz_log(LOG_API,"Hits: %d",hits);
+    yaz_log(YLOG_DEBUG, "Hits: %d",hits);
 
     if (numhits)
        *numhits=hits;
@@ -2133,10 +2132,10 @@ int zebra_sort_by_specstr (ZebraHandle zh,
     int num_input_setnames = 0;
     int sort_status = 0;
     Z_SortKeySpecList *sort_sequence = yaz_sort_spec (stream, sort_spec);
-    yaz_log(LOG_API,"sort (FIXME) ");
+    yaz_log(YLOG_DEBUG, "sort (FIXME) ");
     if (!sort_sequence)
     {
-        logf(LOG_WARN,"invalid sort specs '%s'", sort_spec);
+        yaz_log(YLOG_WARN, "invalid sort specs '%s'", sort_spec);
         zh->errCode = 207;
        return -1;
     }