* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.255 2004-11-02 11:37:21 heikki Exp $
+ * $Id: client.c,v 1.256 2004-11-18 15:18:10 heikki Exp $
*/
#include <stdio.h>
#include <yaz/srw.h>
#include <yaz/yaz-ccl.h>
#include <yaz/cql.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#if HAVE_READLINE_READLINE_H
#include <readline/readline.h>
-## $Id: Makefile.am,v 1.22 2003-07-29 15:08:28 adam Exp $
+## $Id: Makefile.am,v 1.23 2004-11-18 15:18:13 heikki Exp $
pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
- diagbib1.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h oid.h \
+ diagbib1.h sortspec.h ylog.h log.h logrpn.h marcdisp.h nmem.h odr.h oid.h \
options.h otherinfo.h pquery.h prt-ext.h readconf.h statserv.h \
tcpip.h unix.h tpath.h wrbuf.h xmalloc.h \
yaz-ccl.h yaz-iconv.h yaz-util.h yaz-version.h yconfig.h proto.h \
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: log.h,v 1.19 2004-11-16 17:08:11 heikki Exp $
+ * $Id: log.h,v 1.20 2004-11-18 15:18:13 heikki Exp $
*/
/**
* \file log.h
- * \brief Header for logging utility
+ * \brief The old, deprecated header for log.c
*/
#ifndef LOG_H
#define LOG_H
+#include <yaz/ylog.h>
+#warning "use of log.h is deprecated, use logf.h instead"
+
#include <stdio.h>
#include <yaz/yconfig.h>
#include <yaz/xmalloc.h>
YAZ_BEGIN_CDECL
-#define LOG_FATAL 0x00000001
-#define LOG_DEBUG 0x00000002
-#define LOG_WARN 0x00000004
-#define LOG_LOG 0x00000008
-#define LOG_ERRNO 0x00000010 /* append strerror to message */
-#define LOG_FILE 0x00000020
-#define LOG_APP 0x00000040 /* Application level events (new-connection) */
-#define LOG_MALLOC 0x00000080 /* debugging mallocs */
-#define LOG_NOTIME 0x00000100 /* do not output date and time */
-#define LOG_APP2 0x00000200 /* Application-level events, such as api calls */
-#define LOG_APP3 0x00000400 /* For more application-level events */
-#define LOG_FLUSH 0x00000800 /* Flush log after every write (DEBUG does too) */
-#define LOG_LOGLVL 0x00001000 /* log when modules query log levels */
- /* this has to be a hard-coded bit, not to loop*/
-
-#define LOG_ALL (0xffff&~LOG_MALLOC&~LOG_NOTIME)
-
-#define LOG_DEFAULT_LEVEL (LOG_FATAL | LOG_ERRNO | LOG_LOG | LOG_WARN)
-
-#define LOG_LAST_BIT LOG_LOGLVL /* the last bit used for regular log bits */
- /* the rest are for dynamic modules */
-
-#define logf yaz_log
-
-/**
- * yaz_log_init is a shorthand for initializing the log level and prefixes */
-YAZ_EXPORT void yaz_log_init(int level, const char *prefix, const char *name);
-
-/** yaz_log_init_file sets the file name used for yaz_log */
-YAZ_EXPORT void yaz_log_init_file(const char *fname);
-
-/** yaz_log_init_level sets the logging level. Use an OR of the bits above */
-YAZ_EXPORT void yaz_log_init_level(int level);
-
-/** yaz_log_init_prefix sets the log prefix */
-YAZ_EXPORT void yaz_log_init_prefix(const char *prefix);
-
-/** yaz_log_init_prefix2 sets an optional second prefix */
-YAZ_EXPORT void yaz_log_init_prefix2(const char *prefix);
-
-/**
- * yaz_log_time_format sets the format of the timestamp. See man 3 strftime
- * Calling with "old" sets to the old format "11:55:06-02/11"
- * Calling with NULL or "" sets to the new format "20041102-115719"
- * If not called at all, the old format is used, for backward compatibility
- */
-YAZ_EXPORT void yaz_log_time_format(const char *fmt);
-
-/**
- * yaz_log_init_max_size sets the max size for a log file.
- * zero means no limit. Negative means built-in limit (1GB)
+/* The old LOG_ bit names are here for compatibility only. They may
+ * conflict with bits defined in syslog.h, or other places. 'LOG'
+ * really is not such a good name. YLOG must be more unique
*/
-YAZ_EXPORT void yaz_log_init_max_size(int mx);
-
-/**
- * yaz_log writes an entry in the log. Defaults to stderr if not initialized
- * to a file with yaz_log_init_file. The level must match the level set via
- * yaz_log_init_level, optionally defined via yaz_log_mask_str. */
-YAZ_EXPORT void yaz_log(int level, const char *fmt, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 2, 3)))
-#endif
- ;
-
-/**
- * yaz_log_mask_str converts a comma-separated list of log levels to a bit
- * mask. Starts from default level, and adds bits as specified, unless 'none'
- * is specified, which clears the list. If a name matches the name of a
- * LOG_BIT above, that one is set. Otherwise a new value is picked, and given
- * to that name, to be found with yaz_log_module_level */
-YAZ_EXPORT int yaz_log_mask_str(const char *str);
-
-/** yaz_log_mask_str_x is like yaz_log_mask_str, but with a given start value*/
-YAZ_EXPORT int yaz_log_mask_str_x(const char *str, int level);
+#define LOG_FATAL YLOG_FATAL
+#define LOG_DEBUG YLOG_DEBUG
+#define LOG_WARN YLOG_WARN
+#define LOG_LOG YLOG_LOG /* Deprecated, use the modern dynamic log levels*/
+#define LOG_ERRNO YLOG_ERRNO
+ /* LOG_FILE discontinued */
+#define LOG_APP YLOG_APP /* Deprecated */
+ /* LOG_MALLOC discontinued */
+#define LOG_NOTIME YLOG_NOTIME /* do not output date and time */
+#define LOG_APP2 YLOG_APP2 /* deprecated */
+#define LOG_APP3 YLOG_APP3 /* deprecated */
+#define LOG_FLUSH YLOG_FLUSH
+ /* LOG_LOGLVL so new that nobody should be using it. */
+#define LOG_ALL YLOG_ALL
-/**
- * yaz_log_module_level returns a log level mask corresponding to the module
- * name. If that had been specified on the -v arguments (that is, passed to
- * yaz_log_mask_str), then a non-zero mask is returned. If not, we get a
- * zero. This can later be used in yaz_log for the level argument
- */
-YAZ_EXPORT int yaz_log_module_level(const char *name);
-
-/** yaz_log_file returns the file handle for yaz_log. */
-YAZ_EXPORT FILE *yaz_log_file(void);
+#define LOG_DEFAULT_LEVEL YLOG_DEFAULT_LEVEL
-YAZ_EXPORT void log_event_start(void (*func)(int level, const char *msg, void *info),
- void *info);
-YAZ_EXPORT void log_event_end(void (*func)(int level, const char *msg, void *info),
- void *info);
-YAZ_EXPORT void yaz_log_reopen(void);
-YAZ_END_CDECL
#endif
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: yaz-util.h,v 1.10 2004-10-15 00:18:59 adam Exp $
+ * $Id: yaz-util.h,v 1.11 2004-11-18 15:18:13 heikki Exp $
*/
/**
* \file yaz-util.h
#include <yaz/yconfig.h>
#include <yaz/yaz-version.h>
#include <yaz/xmalloc.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h> /* used to be log.h, but that is deprecated */
#include <yaz/tpath.h>
#include <yaz/options.h>
#include <yaz/wrbuf.h>
--- /dev/null
+/*
+ * Copyright (c) 1995-2004, Index Data.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation, in whole or in part, for any purpose, is hereby granted,
+ * provided that:
+ *
+ * 1. This copyright and permission notice appear in all copies of the
+ * software and its documentation. Notices of copyright or attribution
+ * which appear at the beginning of any file must remain unchanged.
+ *
+ * 2. The name of Index Data or the individual authors may not be used to
+ * endorse or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
+ * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ * $Id: ylog.h,v 1.1 2004-11-18 15:18:13 heikki Exp $
+ */
+
+/**
+ * \file log.h
+ * \brief Header for logging utility
+ */
+
+#ifndef YLOG_H
+#define YLOG_H
+
+#include <stdio.h>
+#include <yaz/yconfig.h>
+#include <yaz/xmalloc.h>
+
+YAZ_BEGIN_CDECL
+
+#define YLOG_FATAL 0x00000001
+#define YLOG_DEBUG 0x00000002
+#define YLOG_WARN 0x00000004
+#define YLOG_LOG 0x00000008
+#define YLOG_ERRNO 0x00000010 /* append strerror to message */
+/*#define YLOG_FILE 0x00000020 */
+/*#define YLOG_APP 0x00000040 */
+ /* Application level events (new-connection) */
+#define YLOG_MALLOC 0x00000080 /* debugging mallocs */
+#define YLOG_NOTIME 0x00000100 /* do not output date and time */
+/* #define YLOG_APP2 0x00000200 */
+ /* Application-level events, such as api calls */
+/* #define YLOG_APP3 0x00000400 */
+ /* For more application-level events */
+#define YLOG_FLUSH 0x00000800 /* Flush log after every write (DEBUG does too) */
+#define YLOG_LOGLVL 0x00001000 /* log when modules query log levels */
+ /* this has to be a hard-coded bit, not to loop*/
+
+#define YLOG_ALL (0xffff&~YLOG_MALLOC&~YLOG_NOTIME)
+
+#define YLOG_DEFAULT_LEVEL (YLOG_FATAL | YLOG_ERRNO | YLOG_LOG | YLOG_WARN)
+
+#define YLOG_LAST_BIT YLOG_LOGLVL /* the last bit used for regular log bits */
+ /* the rest are for dynamic modules */
+
+#define logf yaz_log
+
+/**
+ * yaz_log_init is a shorthand for initializing the log level and prefixes */
+YAZ_EXPORT void yaz_log_init(int level, const char *prefix, const char *name);
+
+/** yaz_log_init_file sets the file name used for yaz_log */
+YAZ_EXPORT void yaz_log_init_file(const char *fname);
+
+/** yaz_log_init_level sets the logging level. Use an OR of the bits above */
+YAZ_EXPORT void yaz_log_init_level(int level);
+
+/** yaz_log_init_prefix sets the log prefix */
+YAZ_EXPORT void yaz_log_init_prefix(const char *prefix);
+
+/** yaz_log_init_prefix2 sets an optional second prefix */
+YAZ_EXPORT void yaz_log_init_prefix2(const char *prefix);
+
+/**
+ * yaz_log_time_format sets the format of the timestamp. See man 3 strftime
+ * Calling with "old" sets to the old format "11:55:06-02/11"
+ * Calling with NULL or "" sets to the new format "20041102-115719"
+ * If not called at all, the old format is used, for backward compatibility
+ */
+YAZ_EXPORT void yaz_log_time_format(const char *fmt);
+
+/**
+ * yaz_log_init_max_size sets the max size for a log file.
+ * zero means no limit. Negative means built-in limit (1GB)
+ */
+YAZ_EXPORT void yaz_log_init_max_size(int mx);
+
+/**
+ * yaz_log writes an entry in the log. Defaults to stderr if not initialized
+ * to a file with yaz_log_init_file. The level must match the level set via
+ * yaz_log_init_level, optionally defined via yaz_log_mask_str. */
+YAZ_EXPORT void yaz_log(int level, const char *fmt, ...)
+#ifdef __GNUC__
+ __attribute__ ((format (printf, 2, 3)))
+#endif
+ ;
+
+/**
+ * yaz_log_mask_str converts a comma-separated list of log levels to a bit
+ * mask. Starts from default level, and adds bits as specified, unless 'none'
+ * is specified, which clears the list. If a name matches the name of a
+ * YLOG_BIT above, that one is set. Otherwise a new value is picked, and given
+ * to that name, to be found with yaz_log_module_level */
+YAZ_EXPORT int yaz_log_mask_str(const char *str);
+
+/** yaz_log_mask_str_x is like yaz_log_mask_str, but with a given start value*/
+YAZ_EXPORT int yaz_log_mask_str_x(const char *str, int level);
+
+
+/**
+ * yaz_log_module_level returns a log level mask corresponding to the module
+ * name. If that had been specified on the -v arguments (that is, passed to
+ * yaz_log_mask_str), then a non-zero mask is returned. If not, we get a
+ * zero. This can later be used in yaz_log for the level argument
+ */
+YAZ_EXPORT int yaz_log_module_level(const char *name);
+
+/** yaz_log_file returns the file handle for yaz_log. */
+YAZ_EXPORT FILE *yaz_log_file(void);
+
+YAZ_EXPORT void log_event_start(void (*func)(int level, const char *msg, void *info),
+ void *info);
+YAZ_EXPORT void log_event_end(void (*func)(int level, const char *msg, void *info),
+ void *info);
+
+YAZ_EXPORT void yaz_log_reopen(void);
+YAZ_END_CDECL
+
+#endif
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: eventl.c,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: eventl.c,v 1.3 2004-11-18 15:18:13 heikki Exp $
*/
/**
#include <string.h>
#include <yaz/yconfig.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/comstack.h>
#include <yaz/xmalloc.h>
#include "eventl.h"
#define YAZ_EV_SELECT select
#endif
+static int log_level=0;
+static int log_level_initialized=0;
+
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags)
{
IOCHAN new_iochan;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("eventl");
+ log_level_initialized=1;
+ }
+
if (!(new_iochan = (IOCHAN)xmalloc(sizeof(*new_iochan))))
return 0;
new_iochan->destroyed = 0;
for (p = *iochans; p; p = p->next)
{
time_t w, ftime;
- yaz_log(LOG_DEBUG, "fd=%d flags=%d force_event=%d",
+ yaz_log(log_level, "fd=%d flags=%d force_event=%d",
p->fd, p->flags, p->force_event);
if (p->force_event)
to.tv_sec = 0; /* polling select */
to.tv_sec = w;
}
}
- yaz_log(LOG_DEBUG, "select start %ld", (long) to.tv_sec);
+ yaz_log(log_level, "select start %ld", (long) to.tv_sec);
res = YAZ_EV_SELECT(max + 1, &in, &out, &except, &to);
- yaz_log(LOG_DEBUG, "select end");
+ yaz_log(log_level, "select end");
if (res < 0)
{
if (yaz_errno() == EINTR)
cs_close(conn);
destroy_association(assoc);
iochan_destroy(*iochans);
- yaz_log(LOG_DEBUG, "error select, destroying iochan %p",
+ yaz_log(log_level, "error select, destroying iochan %p",
*iochans);
}
}
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: log.c,v 1.15 2004-11-17 13:03:07 heikki Exp $
+ * $Id: log.c,v 1.16 2004-11-18 15:18:13 heikki Exp $
*/
/**
#include <errno.h>
#include <time.h>
#include <yaz/nmem.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
static NMEM_MUTEX log_mutex = 0;
static int mutex_init_flag = 0; /* not yet initialized */
-static int l_level = LOG_DEFAULT_LEVEL;
+static int l_level = YLOG_DEFAULT_LEVEL;
static FILE *l_file = NULL;
static char l_prefix[512] = "";
static char l_prefix2[512] = "";
char *name;
} mask_names[MAX_MASK_NAMES] =
{
- { LOG_FATAL, "fatal"},
- { LOG_DEBUG, "debug"},
- { LOG_WARN, "warn" },
- { LOG_LOG, "log" },
- { LOG_ERRNO, ""},
- { LOG_MALLOC, "malloc"},
- { LOG_APP, "app" },
- { LOG_NOTIME, "" },
- { LOG_APP2, "app2" },
- { LOG_APP3, "app3" },
- { LOG_ALL, "all" },
- { LOG_FLUSH, "flush" },
- { LOG_LOGLVL, "loglevel" },
+ { YLOG_FATAL, "fatal"},
+ { YLOG_DEBUG, "debug"},
+ { YLOG_WARN, "warn" },
+ { YLOG_LOG, "log" },
+ { YLOG_ERRNO, ""},
+ { YLOG_MALLOC, "malloc"},
+ /* { YLOG_APP, "app" }, */
+ { YLOG_NOTIME, "" },
+ /* { YLOG_APP2, "app2" }, */
+ /* { YLOG_APP3, "app3" }, */
+ { YLOG_ALL, "all" },
+ { YLOG_FLUSH, "flush" },
+ { YLOG_LOGLVL, "loglevel" },
{ 0, "none" },
{ 0, NULL }
/* the rest will be filled in if the user defines dynamic modules*/
};
-static unsigned int next_log_bit = LOG_LAST_BIT<<1; /* first dynamic bit */
+static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
static void init_mutex()
{
{
fclose (l_file);
}
- if (l_level & LOG_FLUSH)
+ if (l_level & YLOG_FLUSH)
setvbuf(new_file, 0, _IONBF, 0);
l_file = new_file;
}
void yaz_log_init_level (int level)
{
- if ( (l_level & LOG_FLUSH) != (level & LOG_FLUSH) )
+ if ( (l_level & YLOG_FLUSH) != (level & YLOG_FLUSH) )
{
l_level = level;
yaz_log_reopen(); /* make sure we set buffering right */
} else
l_level = level;
- if (l_level & LOG_LOGLVL)
+ if (l_level & YLOG_LOGLVL)
{ /* dump the log level bits */
char *bittype="Static ";
int i;
- yaz_log(LOG_LOGLVL,"Setting log level to %d = 0x%08x",l_level,l_level);
+ yaz_log(YLOG_LOGLVL,"Setting log level to %d = 0x%08x",l_level,l_level);
for (i = 0; mask_names[i].name; i++)
if (mask_names[i].mask && *mask_names[i].name)
if (strcmp(mask_names[i].name,"all")!=0)
{
- yaz_log(LOG_LOGLVL,"%s log bit %08x '%s' is %s",
+ yaz_log(YLOG_LOGLVL,"%s log bit %08x '%s' is %s",
bittype, mask_names[i].mask, mask_names[i].name,
(level & mask_names[i].mask)? "ON": "off");
- if (mask_names[i].mask>LOG_LAST_BIT)
+ if (mask_names[i].mask>YLOG_LAST_BIT)
bittype="Dynamic";
}
}
if ( mask_names[i].mask & level)
{
if (*mask_names[i].name && mask_names[i].mask &&
- mask_names[i].mask != LOG_ALL)
+ mask_names[i].mask != YLOG_ALL)
{
sprintf(flags + strlen(flags), "[%s]", mask_names[i].name);
level &= ~mask_names[i].mask;
#endif
#endif
/* WIN32 */
- if (o_level & LOG_ERRNO)
+ if (o_level & YLOG_ERRNO)
{
strcat(buf, " [");
yaz_strerror(buf+strlen(buf), 2048);
(*start_hook_func)(o_level, buf, start_hook_info);
ti = time(0);
tim = localtime(&ti);
- if (l_level & LOG_NOTIME)
+ if (l_level & YLOG_NOTIME)
tbuf[0] = '\0';
else
strftime(tbuf, TIMEFORMAT_LEN-1, l_actual_format, tim);
tbuf[TIMEFORMAT_LEN-1] = '\0';
fprintf(l_file, "%s %s%s %s%s\n", tbuf, l_prefix, flags,
l_prefix2, buf);
- if (l_level & (LOG_FLUSH|LOG_DEBUG) )
+ if (l_level & (YLOG_FLUSH|YLOG_DEBUG) )
fflush(l_file);
if (end_hook_func)
(*end_hook_func)(o_level, buf, end_hook_info);
;
if ( (i>=MAX_MASK_NAMES) || (next_log_bit >= 1<<31 ))
{
- yaz_log(LOG_WARN,"No more log bits left, not logging '%s'", name);
+ yaz_log(YLOG_WARN,"No more log bits left, not logging '%s'", name);
return 0;
}
mask_names[i].mask = next_log_bit;
for (i = 0; mask_names[i].name; i++)
if (0==strcmp(n,mask_names[i].name))
{
- yaz_log(LOG_LOGLVL,"returning log bit 0x%x for '%s' %s",
+ yaz_log(YLOG_LOGLVL,"returning log bit 0x%x for '%s' %s",
mask_names[i].mask, n,
strcmp(n,name)?name:"" );
return mask_names[i].mask;
}
- yaz_log(LOG_LOGLVL,"returning NO log bit for '%s' %s", n,
+ yaz_log(YLOG_LOGLVL,"returning NO log bit for '%s' %s", n,
strcmp(n,name)?name:"" );
return 0;
}
int yaz_log_mask_str (const char *str)
{
- return yaz_log_mask_str_x (str, LOG_DEFAULT_LEVEL);
+ return yaz_log_mask_str_x (str, YLOG_DEFAULT_LEVEL);
}
int yaz_log_mask_str_x (const char *str, int level)
* Copyright (C) 1995-2004, Index Data
* All rights reserved.
*
- * $Id: logrpn.c,v 1.6 2004-11-17 00:18:54 adam Exp $
+ * $Id: logrpn.c,v 1.7 2004-11-18 15:18:13 heikki Exp $
*/
/**
#include <stdio.h>
#include <assert.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/logrpn.h>
+
static const char *relToStr(int v)
{
const char *str = 0;
static void wrbuf_structure (WRBUF b, Z_RPNStructure *zs, enum oid_value ast)
{
- int i;
if (zs->which == Z_RPNStructure_complex)
{
Z_Operator *op = zs->u.complex->roperator;
void log_rpn_query (Z_RPNQuery *rpn)
{
- log_rpn_query_level(LOG_LOG, rpn);
+ log_rpn_query_level(YLOG_LOG, rpn);
}
void log_scan_term_level (int loglevel,
void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast)
{
- log_scan_term_level (LOG_LOG, zapt, ast);
+ log_scan_term_level (YLOG_LOG, zapt, ast);
}
void wrbuf_scan_term(WRBUF b, Z_AttributesPlusTerm *zapt, oid_value ast)
void yaz_log_zquery (Z_Query *q)
{
- yaz_log_zquery_level(LOG_LOG,q);
+ yaz_log_zquery_level(YLOG_LOG,q);
}
void wrbuf_put_zquery(WRBUF b, Z_Query *q)
* Copyright (c) 1995-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: nmem.c,v 1.5 2004-11-03 22:33:17 adam Exp $
+ * $Id: nmem.c,v 1.6 2004-11-18 15:18:13 heikki Exp $
*/
/**
*
* This is a simple and fairly wasteful little module for nibble memory
* allocation. Evemtually we'll put in something better.
+ *
+ * FIXME - it also has some semaphore stuff, and stuff to handle errno.
+ * These should be moved to some other place!
*/
#if HAVE_CONFIG_H
#include <config.h>
#include <errno.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/oid.h>
#ifdef WIN32
#define NMEM_CHUNK (4*1024)
+static int log_level=0;
+static int log_level_initialized=0;
+
#ifdef WIN32
static CRITICAL_SECTION critical_section;
#define NMEM_ENTER EnterCriticalSection(&critical_section)
YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p)
{
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("nmem");
+ log_level_initialized=1;
+ }
+
NMEM_ENTER;
if (!*p)
{
memset(p->buf, 'Y', p->size);
p->next = freelist;
freelist = p;
-#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "nmem free_block p=%p", p);
-#endif
+ if (log_level)
+ yaz_log (log_level, "nmem free_block p=%p", p);
}
#if NMEM_DEBUG
void nmem_print_list (void)
{
- nmem_print_list_l(LOG_DEBUG);
+ if(log_level)
+ nmem_print_list_l(log_level);
}
void nmem_print_list_l (int level)
{
nmem_block *r, *l;
-#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "nmem get_block size=%d", size);
-#endif
+ if (log_level)
+ yaz_log (log_level, "nmem get_block size=%d", size);
+
for (r = freelist, l = 0; r; l = r, r = r->next)
if (r->size >= size)
break;
if (r)
{
-#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "nmem get_block found free block p=%p", r);
-#endif
+ if (log_level)
+ yaz_log (log_level, "nmem get_block found free block p=%p", r);
if (l)
l->next = r->next;
else
if (get < size)
get = size;
-#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "nmem get_block alloc new block size=%d", get);
-#endif
+ if(log_level)
+ yaz_log (log_level, "nmem get_block alloc new block size=%d", get);
+
r = (nmem_block *)xmalloc(sizeof(*r));
r->buf = (char *)xmalloc(r->size = get);
}
void nmem_reset(NMEM n)
{
nmem_block *t;
-
-#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "nmem_reset p=%p", n);
-#endif
+
+ yaz_log (log_level, "nmem_reset p=%p", n);
if (!n)
return;
NMEM_ENTER;
char *r;
#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "%s:%d: nmem_malloc p=%p size=%d", file, line,
- n, size);
+ if (log_level)
+ yaz_log (log_level, "%s:%d: nmem_malloc p=%p size=%d",
+ file, line, n, size);
#endif
if (!n)
{
- yaz_log (LOG_FATAL, "calling nmem_malloc with an null pointer");
+ yaz_log (YLOG_FATAL, "calling nmem_malloc with an null pointer");
abort ();
}
#ifdef WIN32
#if NMEM_DEBUG
struct nmem_debug_info *debug_p;
#endif
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("nmem");
+ log_level_initialized=1;
+ }
NMEM_ENTER;
nmem_active_no++;
NMEM_LEAVE;
#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "%s:%d: nmem_create %d p=%p", file, line,
+ yaz_log (YLOG_DEBUG, "%s:%d: nmem_create %d p=%p", file, line,
nmem_active_no, r);
#endif
r->blocks = 0;
for (debug_p = nmem_debug_list; debug_p; debug_p = debug_p->next)
if (debug_p->p == r)
{
- yaz_log (LOG_FATAL, "multi used block in nmem");
+ yaz_log (YLOG_FATAL, "multi used block in nmem");
abort ();
}
debug_p = xmalloc (sizeof(*debug_p));
return;
#if NMEM_DEBUG
- yaz_log (LOG_DEBUG, "%s:%d: nmem_destroy %d p=%p", file, line,
+ yaz_log (log_level, "%s:%d: nmem_destroy %d p=%p", file, line,
nmem_active_no-1, n);
NMEM_ENTER;
for (debug_p = &nmem_debug_list; *debug_p; debug_p = &(*debug_p)->next)
nmem_print_list();
if (!ok)
{
- yaz_log (LOG_WARN, "%s:%d destroying unallocated nmem block p=%p",
+ yaz_log (YLOG_WARN, "%s:%d destroying unallocated nmem block p=%p",
file, line, n);
return;
}
void nmem_init (void)
{
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("nmem");
+ log_level_initialized=1;
+ }
+
if (++nmem_init_flag == 1)
{
#ifdef WIN32
InitializeCriticalSection(&critical_section);
#elif YAZ_GNU_THREADS
- yaz_log (LOG_LOG, "pth_init");
+ yaz_log (log_level, "pth_init"); /* ??? */
pth_init ();
#endif
nmem_active_no = 0;
void yaz_strerror(char *buf, int max)
{
char *cp;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("nmem");
+ log_level_initialized=1;
+ }
+
#ifdef WIN32
DWORD err = GetLastError();
if (err)
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: odr.c,v 1.8 2004-10-15 00:19:00 adam Exp $
+ * $Id: odr.c,v 1.9 2004-11-18 15:18:13 heikki Exp $
*
*/
#include <stdarg.h>
#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>
#include "odr-priv.h"
+static int log_level=0;
+static int log_level_initialized=0;
+
Odr_null *ODR_NULLVAL = (Odr_null *) "NULL"; /* the presence of a null value */
Odr_null *odr_nullval (void)
return 0;
}
-#include <yaz/log.h>
ODR odr_createmem(int direction)
{
ODR o;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("odr");
+ log_level_initialized=1;
+ }
if (!(o = (ODR)xmalloc(sizeof(*o))))
return 0;
o->op->iconv_handle = 0;
odr_setprint(o, stderr);
odr_reset(o);
- yaz_log (LOG_DEBUG, "odr_createmem dir=%d o=%p", direction, o);
+ yaz_log (log_level, "odr_createmem dir=%d o=%p", direction, o);
return o;
}
void odr_reset(ODR o)
{
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("odr");
+ log_level_initialized=1;
+ }
+
odr_seterror(o, ONONE, 0);
o->bp = o->buf;
odr_seek(o, ODR_S_SET, 0);
o->lenlen = 1;
if (o->op->iconv_handle != 0)
yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
- yaz_log (LOG_DEBUG, "odr_reset o=%p", o);
+ yaz_log (log_level, "odr_reset o=%p", o);
}
void odr_destroy(ODR o)
yaz_iconv_close (o->op->iconv_handle);
xfree(o->op);
xfree(o);
- yaz_log (LOG_DEBUG, "odr_destroy o=%p", o);
+ yaz_log (log_level, "odr_destroy o=%p", o);
}
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: odr_oct.c,v 1.6 2004-10-15 00:19:00 adam Exp $
+ * $Id: odr_oct.c,v 1.7 2004-11-18 15:18:13 heikki Exp $
*/
/**
* \file odr_oct.c
#include <config.h>
#endif
-#include <yaz/log.h>
#include "odr-priv.h"
/*
* Copyright (C) 1994-2004, Index Data
* All rights reserved.
*
- * $Id: readconf.c,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: readconf.c,v 1.3 2004-11-18 15:18:13 heikki Exp $
*/
/**
#include <stdio.h>
#include <ctype.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/readconf.h>
#define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n' || (c) == '\r')
if (!(f = fopen(name, "r")))
{
- yaz_log(LOG_WARN|LOG_ERRNO, "readconf: %s", name);
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "readconf: %s", name);
return -1;
}
for (;;)
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.35 2004-11-16 22:14:44 adam Exp $
+ * $Id: seshigh.c,v 1.36 2004-11-18 15:18:13 heikki Exp $
*/
/**
* \file seshigh.c
#include "session.h"
#include <yaz/proto.h>
#include <yaz/oid.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/logrpn.h>
#include <yaz/statserv.h>
#include <yaz/diagbib1.h>
{
if (!(apduf = fopen(filename, "w")))
{
- yaz_log(LOG_WARN|LOG_ERRNO, "can't open apdu dump %s", filename);
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "can't open apdu dump %s", filename);
return 0;
}
setvbuf(apduf, 0, _IONBF, 0);
sprintf(filename + strlen(filename), ".%d", getpid());
if (!(f = fopen(filename, "w")))
{
- yaz_log(LOG_WARN|LOG_ERRNO, "%s", filename);
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "%s", filename);
return 0;
}
setvbuf(f, 0, _IONBF, 0);
{
if (assoc->state != ASSOC_UP)
{
- yaz_log(LOG_DEBUG, "Final timeout - closing connection.");
+ yaz_log(YLOG_DEBUG, "Final timeout - closing connection.");
/* do we need to lod this at all */
cs_close(conn);
destroy_association(assoc);
yaz_log (log_session, "ir_session (accept)");
if (!cs_accept (conn))
{
- yaz_log (LOG_WARN, "accept failed");
+ yaz_log (YLOG_WARN, "accept failed");
destroy_association(assoc);
iochan_destroy(h);
}
{
if ((assoc->cs_put_mask & EVENT_INPUT) == 0 && (event & assoc->cs_get_mask))
{
- yaz_log(LOG_DEBUG, "ir_session (input)");
+ yaz_log(YLOG_DEBUG, "ir_session (input)");
/* We aren't speaking to this fellow */
if (assoc->state == ASSOC_DEAD)
{
iochan_setevent(h, EVENT_INPUT);
/* we got a complete PDU. Let's decode it */
- yaz_log(LOG_DEBUG, "Got PDU, %d bytes: lead=%02X %02X %02X", res,
+ yaz_log(YLOG_DEBUG, "Got PDU, %d bytes: lead=%02X %02X %02X", res,
assoc->input_buffer[0] & 0xff,
assoc->input_buffer[1] & 0xff,
assoc->input_buffer[2] & 0xff);
odr_setbuf(assoc->decode, assoc->input_buffer, res, 0);
if (!z_GDU(assoc->decode, &req->gdu_request, 0, 0))
{
- yaz_log(LOG_WARN, "ODR error on incoming PDU: %s [element %s] "
+ yaz_log(YLOG_WARN, "ODR error on incoming PDU: %s [element %s] "
"[near byte %d] ",
odr_errmsg(odr_geterror(assoc->decode)),
odr_getelement(assoc->decode),
odr_offset(assoc->decode));
if (assoc->decode->error != OHTTP)
{
- yaz_log(LOG_WARN, "PDU dump:");
+ yaz_log(YLOG_WARN, "PDU dump:");
odr_dumpBER(yaz_log_file(), assoc->input_buffer, res);
request_release(req);
do_close(assoc, Z_Close_protocolError,"Malformed package");
if (assoc->print)
{
if (!z_GDU(assoc->print, &req->gdu_request, 0, 0))
- yaz_log(LOG_WARN, "ODR print error: %s",
+ yaz_log(YLOG_WARN, "ODR print error: %s",
odr_errmsg(odr_geterror(assoc->print)));
odr_reset(assoc->print);
}
request *req = request_head(&assoc->outgoing);
assoc->cs_put_mask = 0;
- yaz_log(LOG_DEBUG, "ir_session (output)");
+ yaz_log(YLOG_DEBUG, "ir_session (output)");
req->state = REQUEST_PENDING;
switch (res = cs_put(conn, req->response, req->len_response))
{
iochan_destroy(h);
break;
case 0: /* all sent - release the request structure */
- yaz_log(LOG_DEBUG, "Wrote PDU, %d bytes", req->len_response);
+ yaz_log(YLOG_DEBUG, "Wrote PDU, %d bytes", req->len_response);
#if 0
- yaz_log(LOG_DEBUG, "HTTP out:\n%.*s", req->len_response,
+ yaz_log(YLOG_DEBUG, "HTTP out:\n%.*s", req->len_response,
req->response);
#endif
nmem_destroy(req->request_mem);
}
if (event & EVENT_EXCEPT)
{
- yaz_log(LOG_WARN, "ir_session (exception)");
+ yaz_log(YLOG_WARN, "ir_session (exception)");
cs_close(conn);
destroy_association(assoc);
iochan_destroy(h);
assoc->backend = 0;
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
- yaz_log(LOG_WARN, "Bad response from backend.");
+ yaz_log(YLOG_WARN, "Bad response from backend.");
return 0;
}
assoc->backend = binitres->handle;
*http_code = 200;
yaz_log(log_requestdetail, "Got SRW SearchRetrieveRequest");
- yaz_log(LOG_DEBUG, "srw_bend_search");
+ yaz_log(YLOG_DEBUG, "srw_bend_search");
if (!assoc->init)
{
- yaz_log(LOG_DEBUG, "srw_bend_init");
+ yaz_log(YLOG_DEBUG, "srw_bend_init");
if (!srw_bend_init(assoc))
{
srw_error = 3; /* assume Authentication error */
srw_res->records[j].recordPacking = packing;
srw_res->records[j].recordData_buf = 0;
- yaz_log(LOG_DEBUG, "srw_bend_fetch %d", i+start);
+ yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start);
errcode = srw_bend_fetch(assoc, i+start, srw_req,
srw_res->records + j);
if (errcode)
*http_code = 404;
if (!assoc->init)
{
- yaz_log(LOG_DEBUG, "srw_bend_init");
+ yaz_log(YLOG_DEBUG, "srw_bend_init");
if (!srw_bend_init(assoc))
{
return;
if (r == 2)
{
r = yaz_srw_decode(hreq, &sr, &soap_package, assoc->decode, &charset);
- yaz_log(LOG_DEBUG, "yaz_srw_decode returned %d", r);
+ yaz_log(YLOG_DEBUG, "yaz_srw_decode returned %d", r);
}
if (r == 2) /* not taken */
{
r = yaz_sru_decode(hreq, &sr, &soap_package, assoc->decode, &charset,
&diagnostic, &num_diagnostic);
- yaz_log(LOG_DEBUG, "yaz_sru_decode returned %d", r);
+ yaz_log(YLOG_DEBUG, "yaz_sru_decode returned %d", r);
}
if (r == 0) /* decode SRW/SRU OK .. */
{
}
if (res)
{
- yaz_log(LOG_DEBUG, " result immediately available");
+ yaz_log(YLOG_DEBUG, " result immediately available");
retval = process_z_response(assoc, req, res);
}
else if (fd < 0)
{
- yaz_log(LOG_DEBUG, " result unavailble");
+ yaz_log(YLOG_DEBUG, " result unavailble");
retval = 0;
}
else /* no result yet - one will be provided later */
/* Set up an I/O handler for the fd supplied by the backend */
- yaz_log(LOG_DEBUG, " establishing handler for result");
+ yaz_log(YLOG_DEBUG, " establishing handler for result");
req->state = REQUEST_PENDING;
if (!(chan = iochan_create(fd, backend_response, EVENT_INPUT)))
abort();
Z_APDU *res;
int fd;
- yaz_log(LOG_DEBUG, "backend_response");
+ yaz_log(YLOG_DEBUG, "backend_response");
assert(assoc && req && req->state != REQUEST_IDLE);
/* determine what it is we're waiting for */
switch (req->apdu_request->which)
res = response_scanRequest(assoc, req, 0, &fd); break;
#endif
default:
- yaz_log(LOG_FATAL, "Serious programmer's lapse or bug");
+ yaz_log(YLOG_FATAL, "Serious programmer's lapse or bug");
abort();
}
if ((res && process_z_response(assoc, req, res) < 0) || fd < 0)
{
- yaz_log(LOG_WARN, "Fatal error when talking to backend");
+ yaz_log(YLOG_WARN, "Fatal error when talking to backend");
do_close(assoc, Z_Close_systemProblem, 0);
iochan_destroy(i);
return;
}
else if (!res) /* no result yet - try again later */
{
- yaz_log(LOG_DEBUG, " no result yet");
+ yaz_log(YLOG_DEBUG, " no result yet");
iochan_setfd(i, fd); /* in case fd has changed */
}
}
if (assoc->print)
{
if (!z_GDU(assoc->print, &res, 0, 0))
- yaz_log(LOG_WARN, "ODR print error: %s",
+ yaz_log(YLOG_WARN, "ODR print error: %s",
odr_errmsg(odr_geterror(assoc->print)));
odr_reset(assoc->print);
}
if (!z_GDU(assoc->encode, &res, 0, 0))
{
- yaz_log(LOG_WARN, "ODR error when encoding PDU: %s [element %s]",
+ yaz_log(YLOG_WARN, "ODR error when encoding PDU: %s [element %s]",
odr_errmsg(odr_geterror(assoc->decode)),
odr_getelement(assoc->decode));
request_release(req);
#if 1
if (request_head(&assoc->incoming))
{
- yaz_log (LOG_DEBUG, "more work to be done");
+ yaz_log (YLOG_DEBUG, "more work to be done");
iochan_setevent(assoc->client_chan, EVENT_WORK);
}
#endif
assoc->backend = 0;
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
- yaz_log(LOG_WARN, "Bad response from backend.");
+ yaz_log(YLOG_WARN, "Bad response from backend.");
return 0;
}
assoc->backend = binitres->handle;
if ((assoc->init->bend_sort))
- yaz_log (LOG_DEBUG, "Sort handler installed");
+ yaz_log (YLOG_DEBUG, "Sort handler installed");
if ((assoc->init->bend_search))
- yaz_log (LOG_DEBUG, "Search handler installed");
+ yaz_log (YLOG_DEBUG, "Search handler installed");
if ((assoc->init->bend_present))
- yaz_log (LOG_DEBUG, "Present handler installed");
+ yaz_log (YLOG_DEBUG, "Present handler installed");
if ((assoc->init->bend_esrequest))
- yaz_log (LOG_DEBUG, "ESRequest handler installed");
+ yaz_log (YLOG_DEBUG, "ESRequest handler installed");
if ((assoc->init->bend_delete))
- yaz_log (LOG_DEBUG, "Delete handler installed");
+ yaz_log (YLOG_DEBUG, "Delete handler installed");
if ((assoc->init->bend_scan))
- yaz_log (LOG_DEBUG, "Scan handler installed");
+ yaz_log (YLOG_DEBUG, "Scan handler installed");
if ((assoc->init->bend_segment))
- yaz_log (LOG_DEBUG, "Segment handler installed");
+ yaz_log (YLOG_DEBUG, "Segment handler installed");
resp->referenceId = req->referenceId;
*options = '\0';
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.35 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.36 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,
if (binitres->errcode)
{
- yaz_log(LOG_DEBUG, "Connection rejected by backend.");
+ yaz_log(YLOG_DEBUG, "Connection rejected by backend.");
*resp->result = 0;
assoc->state = ASSOC_DEAD;
resp->userInformationField = init_diagnostics(assoc->encode,
odr_malloc (assoc->encode, sizeof(*rec));
Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec));
- yaz_log(LOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
+ yaz_log(YLOG_DEBUG, "SurrogateDiagnotic: %d -- %s", error, addinfo);
rec->databaseName = dbname;
rec->which = Z_NamePlusRecord_surrogateDiagnostic;
rec->u.surrogateDiagnostic = drec;
Z_DefaultDiagFormat *rec = (Z_DefaultDiagFormat *)
odr_malloc (assoc->encode, sizeof(*rec));
- yaz_log(LOG_DEBUG, "DiagRecs: %d -- %s", error, addinfo ? addinfo : "");
+ yaz_log(YLOG_DEBUG, "DiagRecs: %d -- %s", error, addinfo ? addinfo : "");
recs->num_diagRecs = 1;
recs->diagRecs = recp;
this_length = freq.len;
else
this_length = odr_total(a->encode) - total_length - dumped_records;
- yaz_log(LOG_DEBUG, " fetched record, len=%d, total=%d dumped=%d",
+ yaz_log(YLOG_DEBUG, " fetched record, len=%d, total=%d dumped=%d",
this_length, total_length, dumped_records);
if (a->preferredMessageSize > 0 &&
this_length + total_length > a->preferredMessageSize)
yaz_log(log_requestdetail, " Record > prefmsgsz");
if (toget > 1)
{
- yaz_log(LOG_DEBUG, " Dropped it");
+ yaz_log(YLOG_DEBUG, " Dropped it");
reclist->records[reclist->num_records] =
surrogatediagrec(a, freq.basename, 16, 0);
reclist->num_records++;
else
{
/* FIXME - make a diagnostic for it */
- yaz_log(LOG_WARN,"Search not supported ?!?!");
+ yaz_log(YLOG_WARN,"Search not supported ?!?!");
}
return response_searchRequest(assoc, reqb, bsrr, fd);
}
*fd = -1;
if (!bsrt && !bend_searchresponse(assoc->backend, bsrt))
{
- yaz_log(LOG_FATAL, "Bad result from backend");
+ yaz_log(YLOG_FATAL, "Bad result from backend");
return 0;
}
else if (bsrt->errcode)
odr_malloc(assoc->encode, o->len = o->size =
strlen(bsrr->entries[i].term));
memcpy(o->buf, bsrr->entries[i].term, o->len);
- yaz_log(LOG_DEBUG, " term #%d: '%s' (%d)", i,
+ yaz_log(YLOG_DEBUG, " term #%d: '%s' (%d)", i,
bsrr->entries[i].term, bsrr->entries[i].occurrences);
}
else
int r;
r = process_z_request (a, req, &msg);
if (r < 0)
- yaz_log (LOG_WARN, "%s", msg);
+ yaz_log (YLOG_WARN, "%s", msg);
return r;
}
esrequest.errstring);
/* Backend indicates error, request will not be processed */
- yaz_log(LOG_DEBUG,"Request could not be processed...failure !");
+ yaz_log(YLOG_DEBUG,"Request could not be processed...failure !");
*resp->operationStatus = Z_ExtendedServicesResponse_failure;
resp->num_diagnostics = diagRecs->num_diagRecs;
resp->diagnostics = diagRecs->diagRecs;
resp->taskPackage = z_ext_record (assoc->encode, VAL_EXTENDED,
(const char *) esrequest.taskPackage,
-1);
- yaz_log(LOG_DEBUG,"Send the result apdu");
+ yaz_log(YLOG_DEBUG,"Send the result apdu");
return apdu;
}
* NT threaded server code by
* Chas Woodfield, Fretwell Downing Informatics.
*
- * $Id: statserv.c,v 1.11 2004-11-16 17:08:11 heikki Exp $
+ * $Id: statserv.c,v 1.12 2004-11-18 15:18:13 heikki Exp $
*/
/**
#ifdef USE_XTIMOSI
#include <yaz/xmosi.h>
#endif
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include "eventl.h"
#include "session.h"
#include <yaz/statserv.h>
1, /* dynamic mode */
0, /* threaded mode */
0, /* one shot (single session) */
- LOG_DEFAULT_LEVEL, /* log level */
+ YLOG_DEFAULT_LEVEL, /* log level */
"", /* no PDUs */
"", /* diagnostic output to stderr */
"tcp:@:9999", /* default listener port */
{
if ((res = cs_listen(line, 0, 0)) < 0)
{
- yaz_log(LOG_FATAL, "cs_listen failed");
+ yaz_log(YLOG_FATAL, "cs_listen failed");
return;
}
else if (res == 1)
return;
- yaz_log(LOG_DEBUG, "listen ok");
+ yaz_log(YLOG_DEBUG, "listen ok");
iochan_setevent(h, EVENT_OUTPUT);
iochan_setflags(h, EVENT_OUTPUT | EVENT_EXCEPT); /* set up for acpt */
}
if (!new_line)
{
- yaz_log(LOG_FATAL, "Accept failed.");
+ yaz_log(YLOG_FATAL, "Accept failed.");
iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT);
return;
}
- yaz_log(LOG_DEBUG, "Accept ok");
+ yaz_log(YLOG_DEBUG, "Accept ok");
if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session,
EVENT_INPUT)))
{
- yaz_log(LOG_FATAL, "Failed to create iochan");
+ yaz_log(YLOG_FATAL, "Failed to create iochan");
iochan_destroy(h);
return;
}
- yaz_log(LOG_DEBUG, "Creating association");
+ yaz_log(YLOG_DEBUG, "Creating association");
if (!(newas = create_association(new_chan, new_line)))
{
- yaz_log(LOG_FATAL, "Failed to create new assoc.");
+ yaz_log(YLOG_FATAL, "Failed to create new assoc.");
iochan_destroy(h);
return;
}
newas->cs_put_mask = 0;
newas->cs_accept_mask = 0;
- yaz_log(LOG_DEBUG, "Setting timeout %d", control_block.idle_timeout);
+ yaz_log(YLOG_DEBUG, "Setting timeout %d", control_block.idle_timeout);
iochan_setdata(new_chan, newas);
iochan_settimeout(new_chan, 60);
if (newHandle == (HANDLE) -1)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to create new thread.");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create new thread.");
iochan_destroy(h);
return;
}
/* We successfully created the thread, so add it to the list */
statserv_add(newHandle, new_chan);
- yaz_log(LOG_DEBUG, "Created new thread, id = %ld iochan %p",(long) newHandle, new_chan);
+ yaz_log(YLOG_DEBUG, "Created new thread, id = %ld iochan %p",(long) newHandle, new_chan);
iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
}
else
{
- yaz_log(LOG_FATAL, "Bad event on listener.");
+ yaz_log(YLOG_FATAL, "Bad event on listener.");
iochan_destroy(h);
return;
}
++no_sessions;
if (pipe(hand) < 0)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "pipe");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "pipe");
iochan_destroy(h);
return;
}
if ((res = fork()) < 0)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "fork");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "fork");
iochan_destroy(h);
return;
}
if ((res = read(hand[0], dummy, 1)) < 0 &&
yaz_errno() != EINTR)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "handshake read");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "handshake read");
return;
}
else if (res >= 0)
break;
}
- yaz_log(LOG_DEBUG, "P: Child has taken the call");
+ yaz_log(YLOG_DEBUG, "P: Child has taken the call");
close(hand[0]);
return;
}
if ((res = cs_listen_check(line, 0, 0, control_block.check_ip,
control_block.daemon_name)) < 0)
{
- yaz_log(LOG_WARN|LOG_ERRNO, "cs_listen failed");
+ yaz_log(YLOG_WARN|YLOG_ERRNO, "cs_listen failed");
return;
}
else if (res == 1)
return;
- yaz_log(LOG_DEBUG, "listen ok");
+ yaz_log(YLOG_DEBUG, "listen ok");
iochan_setevent(h, EVENT_OUTPUT);
iochan_setflags(h, EVENT_OUTPUT | EVENT_EXCEPT); /* set up for acpt */
}
if (!new_line)
{
- yaz_log(LOG_FATAL, "Accept failed.");
+ yaz_log(YLOG_FATAL, "Accept failed.");
iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
return;
}
- yaz_log(LOG_DEBUG, "accept ok");
+ yaz_log(YLOG_DEBUG, "accept ok");
if (control_block.dynamic)
{
IOCHAN pp;
iochan_destroy(pp);
}
/* release dad */
- yaz_log(LOG_DEBUG, "Releasing parent");
+ yaz_log(YLOG_DEBUG, "Releasing parent");
close(hand[1]);
}
else
pth_attr_set (attr, PTH_ATTR_JOINABLE, FALSE);
pth_attr_set (attr, PTH_ATTR_STACK_SIZE, 32*1024);
pth_attr_set (attr, PTH_ATTR_NAME, "session");
- yaz_log (LOG_DEBUG, "pth_spawn begin");
+ yaz_log (YLOG_DEBUG, "pth_spawn begin");
child_thread = pth_spawn (attr, new_session, new_line);
- yaz_log (LOG_DEBUG, "pth_spawn finish");
+ yaz_log (YLOG_DEBUG, "pth_spawn finish");
pth_attr_destroy (attr);
}
else
}
else
{
- yaz_log(LOG_FATAL, "Bad event on listener.");
+ yaz_log(YLOG_FATAL, "Bad event on listener.");
iochan_destroy(h);
}
}
if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session, mask)))
{
- yaz_log(LOG_FATAL, "Failed to create iochan");
+ yaz_log(YLOG_FATAL, "Failed to create iochan");
return 0;
}
if (!(newas = create_association(new_chan, new_line)))
{
- yaz_log(LOG_FATAL, "Failed to create new assoc.");
+ yaz_log(YLOG_FATAL, "Failed to create new assoc.");
return 0;
}
newas->cs_accept_mask = cs_accept_mask;
}
else
{
- yaz_log(LOG_FATAL, "Failed to create association structure");
+ yaz_log(YLOG_FATAL, "Failed to create association structure");
}
chan->next = pListener;
pListener = chan;
}
else
{
- yaz_log(LOG_FATAL, "Failed to create iochan");
+ yaz_log(YLOG_FATAL, "Failed to create iochan");
}
}
else
{
- yaz_log(LOG_ERRNO|LOG_FATAL, "Failed to create comstack on socket 0");
+ yaz_log(YLOG_ERRNO|YLOG_FATAL, "Failed to create comstack on socket 0");
}
}
l = cs_create_host(where, 2, &ap);
if (!l)
{
- yaz_log(LOG_FATAL, "Failed to listen on %s", where);
+ yaz_log(YLOG_FATAL, "Failed to listen on %s", where);
return -1;
}
if (*control_block.cert_fname)
if (cs_bind(l, ap, CS_SERVER) < 0)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", where);
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where);
cs_close (l);
return -1;
}
if (!(lst = iochan_create(cs_fileno(l), listener, EVENT_INPUT |
EVENT_EXCEPT)))
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to create IOCHAN-type");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create IOCHAN-type");
cs_close (l);
return -1;
}
FILE *f = fopen(control_block.pid_fname, "w");
if (!f)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "Couldn't create %s",
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Couldn't create %s",
control_block.pid_fname);
exit(0);
}
if (!(pw = getpwnam(control_block.setuid)))
{
- yaz_log(LOG_FATAL, "%s: Unknown user", control_block.setuid);
+ yaz_log(YLOG_FATAL, "%s: Unknown user", control_block.setuid);
return(1);
}
if (setuid(pw->pw_uid) < 0)
{
- yaz_log(LOG_FATAL|LOG_ERRNO, "setuid");
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid");
exit(1);
}
}
ret = 1;
else
{
- yaz_log(LOG_DEBUG, "Entering event loop.");
+ yaz_log(YLOG_DEBUG, "Entering event loop.");
ret = event_loop(&pListener);
}
return ret;
case 'p':
if (strlen(arg) >= sizeof(control_block.pid_fname))
{
- yaz_log(LOG_FATAL, "pid fname too long");
+ yaz_log(YLOG_FATAL, "pid fname too long");
exit(1);
}
strcpy(control_block.pid_fname, arg);
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: tcpdchk.c,v 1.2 2004-10-15 00:19:01 adam Exp $
+ * $Id: tcpdchk.c,v 1.3 2004-11-18 15:18:13 heikki Exp $
*/
/**
* \file tcpdchk.c
#include <yaz/yconfig.h>
#include <yaz/comstack.h>
+#include <yaz/statserv.h>
+#include <yaz/ylog.h>
+
#if HAVE_TCPD_H
#include <syslog.h>
#include <tcpd.h>
-int allow_severity = LOG_INFO;
+int allow_severity = LOG_INFO; /* not YLOG !! */
int deny_severity = LOG_WARNING;
#ifdef LOG_DEBUG
#endif
-#include <yaz/statserv.h>
-#include <yaz/log.h>
-
int check_ip_tcpd(void *cd, const char *addr, int len, int type)
{
const char *daemon_name = (const char *) cd;
i = hosts_access(&request_info);
if (!i)
{
- yaz_log (LOG_DEBUG, "access denied from %s",
+ yaz_log (YLOG_DEBUG, "access denied from %s",
host_name ? host_name : host_addr);
return 1;
}
- yaz_log (LOG_DEBUG, "access granted from %s",
+ yaz_log (YLOG_DEBUG, "access granted from %s",
host_name ? host_name : host_addr);
#endif
}
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.11 2004-10-15 00:19:01 adam Exp $
+ * $Id: tcpip.c,v 1.12 2004-11-18 15:18:14 heikki Exp $
*/
/**
* \file tcpip.c
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
-#include <yaz/log.h>
#include <yaz/nmem.h>
#ifdef WIN32
* Copyright (c) 1995-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: tpath.c,v 1.2 2004-10-15 00:19:01 adam Exp $
+ * $Id: tpath.c,v 1.3 2004-11-18 15:18:14 heikki Exp $
*/
/**
* \file tpath.c
#include <string.h>
#include <ctype.h>
#include <yaz/tpath.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
FILE *yaz_path_fopen(const char *path, const char *name, const char *mode)
{
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: unix.c,v 1.6 2004-10-15 00:19:01 adam Exp $
+ * $Id: unix.c,v 1.7 2004-11-18 15:18:14 heikki Exp $
* UNIX socket COMSTACK. By Morten Bøgeskov.
*/
/**
#include <yaz/comstack.h>
#include <yaz/unix.h>
-#include <yaz/log.h>
#include <yaz/nmem.h>
#ifndef YAZ_SOCKLEN_T
* Copyright (C) 1994-2004, Index Data
* All rights reserved.
*
- * $Id: xmalloc.c,v 1.2 2004-10-15 00:19:01 adam Exp $
+ * $Id: xmalloc.c,v 1.3 2004-11-18 15:18:14 heikki Exp $
*/
/**
* \file xmalloc.c
#include <stdlib.h>
#include <string.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/xmalloc.h>
#ifndef TRACE_XMALLOC
#define TRACE_XMALLOC 1
#endif
+static int log_level=0;
+static int log_level_initialized=0;
+
#if TRACE_XMALLOC > 1
static const unsigned char head[] = {88, 77, 66, 55, 44, 33, 22, 11};
struct dmalloc_info *dmalloc_list = 0;
+
void *xmalloc_d(size_t nbytes, const char *file, int line)
{
char *res;
struct dmalloc_info *dinfo;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
if (!(res = (char*) malloc(nbytes + sizeof(*dinfo)+16*sizeof(char))))
return 0;
dinfo = (struct dmalloc_info *) res;
((char*)ptr - 8*sizeof(char) - sizeof(*dinfo));
if (memcmp(head, (char*) ptr - 8*sizeof(char), 8*sizeof(char)))
{
- yaz_log(LOG_FATAL, "xfree_d bad head, %s:%d, %p", file, line, ptr);
+ yaz_log(YLOG_FATAL, "xfree_d bad head, %s:%d, %p", file, line, ptr);
abort();
}
if (memcmp((char*) ptr + dinfo->len, tail, 8*sizeof(char)))
{
- yaz_log(LOG_FATAL, "xfree_d bad tail, %s:%d, %p", file, line, ptr);
+ yaz_log(YLOG_FATAL, "xfree_d bad tail, %s:%d, %p", file, line, ptr);
abort();
}
if (dinfo->prev)
char *ptr = (char*) p;
char *res;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
if (!ptr)
{
if (!nbytes)
{
if (memcmp(head, ptr - 8*sizeof(char), 8*sizeof(char)))
{
- yaz_log(LOG_FATAL, "xrealloc_d bad head, %s:%d, %p",
+ yaz_log(YLOG_FATAL, "xrealloc_d bad head, %s:%d, %p",
file, line, ptr);
abort();
}
dinfo = (struct dmalloc_info *) (ptr-8*sizeof(char) - sizeof(*dinfo));
if (memcmp(ptr + dinfo->len, tail, 8*sizeof(char)))
{
- yaz_log(LOG_FATAL, "xrealloc_d bad tail, %s:%d, %p",
+ yaz_log(YLOG_FATAL, "xrealloc_d bad tail, %s:%d, %p",
file, line, ptr);
abort();
}
struct dmalloc_info *dinfo;
size_t nbytes = nmemb * size;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
if (!(res = (char*) calloc(1, nbytes+sizeof(*dinfo)+16*sizeof(char))))
return 0;
dinfo = (struct dmalloc_info *) res;
size_t size = 0;
struct dmalloc_info *dinfo = dmalloc_list;
- yaz_log (LOG_MALLOC, "malloc_trav %s:%d", file, line);
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
+ yaz_log (log_level, "malloc_trav %s:%d", file, line);
while (dinfo)
{
- yaz_log (LOG_MALLOC, " %20s:%d p=%p size=%d", dinfo->file, dinfo->line,
+ yaz_log (log_level, " %20s:%d p=%p size=%d", dinfo->file, dinfo->line,
((char*) dinfo)+sizeof(*dinfo)+8*sizeof(char), dinfo->len);
size += dinfo->len;
dinfo = dinfo->next;
}
- yaz_log (LOG_MALLOC, "total bytes %ld", (long) size);
+ yaz_log (log_level, "total bytes %ld", (long) size);
}
#else
void xmalloc_trav_f(const char *s, const char *file, int line)
{
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
xmalloc_trav_d(file, line);
}
{
void *p = xrealloc_d (o, size, file, line);
-#if TRACE_XMALLOC
- yaz_log (LOG_MALLOC,
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
+ if(log_level)
+ yaz_log (log_level,
"%s:%d: xrealloc(s=%d) %p -> %p", file, line, size, o, p);
-#endif
if (!p)
{
- yaz_log (LOG_FATAL|LOG_ERRNO, "Out of memory, realloc (%d bytes)",
+ yaz_log (YLOG_FATAL|YLOG_ERRNO, "Out of memory, realloc (%d bytes)",
size);
exit(1);
}
{
void *p = xmalloc_d (size, file, line);
-#if TRACE_XMALLOC
- yaz_log (LOG_MALLOC, "%s:%d: xmalloc(s=%d) %p", file, line, size, p);
-#endif
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
+ if (log_level)
+ yaz_log (log_level, "%s:%d: xmalloc(s=%d) %p", file, line, size, p);
+
if (!p)
{
- yaz_log (LOG_FATAL, "Out of memory - malloc (%d bytes)", size);
+ yaz_log (YLOG_FATAL, "Out of memory - malloc (%d bytes)", size);
exit (1);
}
return p;
void *xcalloc_f (size_t nmemb, size_t size, const char *file, int line)
{
void *p = xcalloc_d (nmemb, size, file, line);
-#if TRACE_XMALLOC
- yaz_log (LOG_MALLOC, "%s:%d: xcalloc(s=%d) %p", file, line, size, p);
-#endif
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
+ if (log_level)
+ yaz_log (log_level, "%s:%d: xcalloc(s=%d) %p", file, line, size, p);
+
if (!p)
{
- yaz_log (LOG_FATAL, "Out of memory - calloc (%d, %d)", nmemb, size);
+ yaz_log (YLOG_FATAL, "Out of memory - calloc (%d, %d)", nmemb, size);
exit (1);
}
return p;
char *xstrdup_f (const char *s, const char *file, int line)
{
char *p = (char *)xmalloc_d (strlen(s)+1, file, line);
-#if TRACE_XMALLOC
- yaz_log (LOG_MALLOC, "%s:%d: xstrdup(s=%d) %p", file, line, strlen(s)+1, p);
-#endif
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("malloc");
+ log_level_initialized=1;
+ }
+
+ if (log_level)
+ yaz_log (log_level, "%s:%d: xstrdup(s=%d) %p", file, line, strlen(s)+1, p);
+
strcpy (p, s);
return p;
}
{
if (!p)
return ;
-#if TRACE_XMALLOC
- if (p)
- yaz_log (LOG_MALLOC, "%s:%d: xfree %p", file, line, p);
-#endif
+ if (log_level)
+ yaz_log (log_level, "%s:%d: xfree %p", file, line, p);
xfree_d(p, file, line);
}
* Copyright (c) 2000-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.31 2004-10-15 00:19:01 adam Exp $
+ * $Id: zoom-c.c,v 1.32 2004-11-18 15:18:14 heikki Exp $
*/
/**
* \file zoom-c.c
#include <yaz/yaz-util.h>
#include <yaz/xmalloc.h>
#include <yaz/otherinfo.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/pquery.h>
#include <yaz/marcdisp.h>
#include <yaz/diagbib1.h>
#include <sys/poll.h>
#endif
+static int log_level=0;
+static int log_level_initialized=0;
+
typedef enum {
zoom_pending,
zoom_complete
const char *addinfo, const char *addinfo2)
{
char *cp;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("zoom");
+ log_level_initialized=1;
+ }
+
xfree (c->addinfo);
c->addinfo = 0;
c->error = error;
else if (addinfo)
c->addinfo = xstrdup(addinfo);
if (error)
- yaz_log(LOG_DEBUG, "Error %s %s:%d %s %s",
+ yaz_log(log_level, "Error %s %s:%d %s %s",
c->host_port ? c->host_port : "<>", dset, error,
addinfo ? addinfo : "",
addinfo2 ? addinfo2 : "");
{
ZOOM_connection c = (ZOOM_connection) xmalloc (sizeof(*c));
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("zoom");
+ log_level_initialized=1;
+ }
+
c->proto = PROTO_Z3950;
c->cs = 0;
c->mask = 0;
const char *val;
ZOOM_task task;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("zoom");
+ log_level_initialized=1;
+ }
+
if (c->cs)
{
- yaz_log (LOG_DEBUG, "reconnect");
+ yaz_log (log_level, "reconnect");
c->reconnect_ok = 1;
return;
}
- yaz_log(LOG_DEBUG, "connect");
+ yaz_log(log_level, "connect");
xfree (c->proxy);
val = ZOOM_options_get (c->options, "proxy");
if (val && *val)
return;
(s->refcount)--;
- yaz_log (LOG_DEBUG, "ZOOM_query_destroy count=%d", s->refcount);
+ yaz_log (log_level, "ZOOM_query_destroy count=%d", s->refcount);
if (s->refcount == 0)
{
odr_destroy (s->odr);
if (r)
{
(r->refcount)++;
- yaz_log (LOG_DEBUG, "ZOOM_resultset_addref r=%p count=%d",
+ yaz_log (log_level, "ZOOM_resultset_addref r=%p count=%d",
r, r->refcount);
}
}
{
ZOOM_resultset r = (ZOOM_resultset) xmalloc (sizeof(*r));
- yaz_log (LOG_DEBUG, "ZOOM_resultset_create r = %p", r);
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("zoom");
+ log_level_initialized=1;
+ }
+
+ yaz_log (log_level, "ZOOM_resultset_create r = %p", r);
r->refcount = 1;
r->size = 0;
r->odr = odr_createmem (ODR_ENCODE);
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
if (!r)
return;
(r->refcount)--;
- yaz_log (LOG_DEBUG, "ZOOM_resultset_destroy r = %p count=%d",
+ yaz_log (log_level, "ZOOM_resultset_destroy r = %p count=%d",
r, r->refcount);
if (r->refcount == 0)
{
{
if (!c->cs)
{
- yaz_log(LOG_DEBUG, "NO COMSTACK");
+ yaz_log(log_level, "NO COMSTACK");
ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
}
else
{
- yaz_log(LOG_DEBUG, "PREPARE FOR RECONNECT");
+ yaz_log(log_level, "PREPARE FOR RECONNECT");
c->reconnect_ok = 1;
}
}
{
void *add;
const char *effective_host;
+ if (!log_level_initialized)
+ {
+ log_level=yaz_log_module_level("zoom");
+ log_level_initialized=1;
+ }
+
if (c->proxy)
effective_host = c->proxy;
else
effective_host = c->host_port;
- yaz_log (LOG_DEBUG, "do_connect host=%s", effective_host);
+ yaz_log (log_level, "do_connect host=%s", effective_host);
if (c->cs)
cs_close(c->cs);
z_APDU(odr_pr, &a, 0, 0);
odr_destroy(odr_pr);
}
- yaz_log (LOG_DEBUG, "encoding failed");
+ yaz_log (log_level, "encoding failed");
set_ZOOM_error(c, ZOOM_ERROR_ENCODE, 0);
odr_reset(out);
return -1;
assert (a);
if (encode_APDU(c, a, c->odr_out))
return zoom_complete;
- yaz_log(LOG_DEBUG, "send APDU type=%d", a->which);
+ yaz_log(log_level, "send APDU type=%d", a->which);
c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
event = ZOOM_Event_create (ZOOM_EVENT_SEND_APDU);
ZOOM_connection_put_event (c, event);
ZOOM_options_get(c->options, "implementationName"),
odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.31 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.32 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion = odr_prepend(c->odr_out,
break;
}
r->setname = xstrdup (setname);
- yaz_log (LOG_DEBUG, "allocating set %s", r->setname);
+ yaz_log (log_level, "allocating set %s", r->setname);
}
else
r->setname = xstrdup ("default");
ZOOM_resultset resultset;
ZOOM_Event event;
- yaz_log (LOG_DEBUG, "got search response");
+ yaz_log (log_level, "got search response");
if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
return ;
if (!task)
{
- yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task task=<null>");
+ yaz_log (log_level, "ZOOM_connection_exec_task task=<null>");
return 0;
}
- yaz_log (LOG_DEBUG, "ZOOM_connection_exec_task type=%d run=%d",
+ yaz_log (log_level, "ZOOM_connection_exec_task type=%d run=%d",
task->which, task->running);
if (c->error != ZOOM_ERROR_NONE)
{
- yaz_log (LOG_DEBUG, "remove tasks because of error = %d", c->error);
+ yaz_log (log_level, "remove tasks because of error = %d", c->error);
ZOOM_connection_remove_tasks (c);
return 0;
}
if (task->running)
{
- yaz_log (LOG_DEBUG, "task already running");
+ yaz_log (log_level, "task already running");
return 0;
}
task->running = 1;
}
else
{
- yaz_log (LOG_DEBUG, "remove tasks because no connection exist");
+ yaz_log (log_level, "remove tasks because no connection exist");
ZOOM_connection_remove_tasks (c);
}
if (ret == zoom_complete)
{
- yaz_log (LOG_DEBUG, "task removed (complete)");
+ yaz_log (log_level, "task removed (complete)");
ZOOM_connection_remove_task (c);
return 0;
}
- yaz_log (LOG_DEBUG, "task pending");
+ yaz_log (log_level, "task pending");
return 1;
}
Z_InitResponse *initrs;
c->mask = 0;
- yaz_log (LOG_DEBUG, "recv APDU type=%d", apdu->which);
+ yaz_log (log_level, "recv APDU type=%d", apdu->which);
switch(apdu->which)
{
case Z_APDU_initResponse:
int sel;
yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
- yaz_log(LOG_DEBUG, "Target accepted: charset %s, "
+ yaz_log(log_level, "Target accepted: charset %s, "
"language %s, select %d",
charset ? charset : "none", lang ? lang : "none", sel);
if (charset)
resultset->size = 0;
- yaz_log(LOG_DEBUG, "got SRW response OK");
+ yaz_log(log_level, "got SRW response OK");
if (res->numberOfRecords)
resultset->size = *res->numberOfRecords;
const char *connection_head = z_HTTP_header_lookup(hres->headers,
"Connection");
c->mask = 0;
- yaz_log (LOG_DEBUG, "handle_http");
+ yaz_log (log_level, "handle_http");
if (content_type && !yaz_strcmp_del("text/xml", content_type, "; "))
{
r = cs_get (c->cs, &c->buf_in, &c->len_in);
more = cs_more(c->cs);
- yaz_log (LOG_DEBUG, "do_read len=%d more=%d", r, more);
+ yaz_log (log_level, "do_read len=%d more=%d", r, more);
if (r == 1)
return 0;
if (r <= 0)
{
do_close (c);
c->reconnect_ok = 0;
- yaz_log (LOG_DEBUG, "reconnect read");
+ yaz_log (log_level, "reconnect read");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
}
event = ZOOM_Event_create(ZOOM_EVENT_SEND_DATA);
ZOOM_connection_put_event (c, event);
- yaz_log (LOG_DEBUG, "do_write_ex len=%d", len_out);
+ yaz_log (log_level, "do_write_ex len=%d", len_out);
if ((r=cs_put (c->cs, buf_out, len_out)) < 0)
{
if (c->reconnect_ok)
{
do_close (c);
c->reconnect_ok = 0;
- yaz_log (LOG_DEBUG, "reconnect write");
+ yaz_log (log_level, "reconnect write");
c->tasks->running = 0;
ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
return zoom_pending;
c->mask += ZOOM_SELECT_WRITE;
if (c->cs->io_pending & CS_WANT_READ)
c->mask += ZOOM_SELECT_READ;
- yaz_log (LOG_DEBUG, "do_write_ex 1 mask=%d", c->mask);
+ yaz_log (log_level, "do_write_ex 1 mask=%d", c->mask);
}
else
{
c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_EXCEPT;
- yaz_log (LOG_DEBUG, "do_write_ex 2 mask=%d", c->mask);
+ yaz_log (log_level, "do_write_ex 2 mask=%d", c->mask);
}
return zoom_pending;
}
{
ZOOM_Event event = 0;
int r = cs_look(c->cs);
- yaz_log (LOG_DEBUG, "ZOOM_connection_do_io c=%p mask=%d cs_look=%d",
+ yaz_log (log_level, "ZOOM_connection_do_io c=%p mask=%d cs_look=%d",
c, mask, r);
if (r == CS_NONE)
event = ZOOM_Event_create (ZOOM_EVENT_CONNECT);
ret = cs_rcvconnect (c->cs);
- yaz_log (LOG_DEBUG, "cs_rcvconnect returned %d", ret);
+ yaz_log (log_level, "cs_rcvconnect returned %d", ret);
if (ret == 1)
{
c->mask = ZOOM_SELECT_EXCEPT;
#else
tv.tv_sec = timeout;
tv.tv_usec = 0;
- yaz_log (LOG_DEBUG, "select start");
+ yaz_log (log_level, "select start");
r = select (max_fd+1, &input, &output, &except, &tv);
- yaz_log (LOG_DEBUG, "select stop, returned r=%d", r);
+ yaz_log (log_level, "select stop, returned r=%d", r);
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
/* timeout and this connection was waiting */
set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
do_close (c);
- yaz_log (LOG_DEBUG, "timeout");
+ yaz_log (log_level, "timeout");
ZOOM_connection_put_event(c, event);
}
}
* 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 $
+ * $Id: tstlog.c,v 1.2 2004-11-18 15:18:14 heikki Exp $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <yaz/options.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
int main(int argc, char **argv)
{
char *arg;
int ret;
- int level = LOG_LOG;
+ int level = YLOG_LOG;
while ((ret = options("f:v:l:m:", argv, argc, &arg)) != -2)
{
* Copyright (c) 2002-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: zoomsh.c,v 1.29 2004-04-29 08:54:56 adam Exp $
+ * $Id: zoomsh.c,v 1.30 2004-11-18 15:18:14 heikki Exp $
*/
/* ZOOM-C Shell */
#include <yaz/xmalloc.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#include <yaz/nmem.h>
#include <yaz/zoom.h>
#include <yaz/oid.h>
ZOOM_options options,
const char **args)
{
- yaz_log_init_level(LOG_ALL);
+ yaz_log_init_level(YLOG_ALL);
}
static void cmd_search (ZOOM_connection *c, ZOOM_resultset *r,
* Copyright (c) 1995-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: read-grs.c,v 1.8 2003-01-06 08:20:29 adam Exp $
+ * $Id: read-grs.c,v 1.9 2004-11-18 15:18:14 heikki Exp $
*/
/*
#include <stdlib.h>
#include <yaz/proto.h>
-#include <yaz/log.h>
+#include <yaz/ylog.h>
#define GRS_MAX_FIELDS 50
return r;
if (sscanf(buf, "(%d,%[^)])", &type, value) != 2)
{
- yaz_log(LOG_WARN, "Bad data in '%s'", buf);
+ yaz_log(YLOG_WARN, "Bad data in '%s'", buf);
return 0;
}
if (!type && *value == '0')
* Copyright (c) 1995-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: ztest.c,v 1.66 2004-11-16 17:08:11 heikki Exp $
+ * $Id: ztest.c,v 1.67 2004-11-18 15:18:14 heikki Exp $
*/
/*
/* if database is stop, stop this process.. For debugging only. */
if (!yaz_matchstr (rr->basenames[0], "stop"))
{
- nmem_print_list_l(LOG_LOG);
+ nmem_print_list_l(YLOG_LOG);
exit(0);
}
#endif
}
else
{
- yaz_log (LOG_WARN, "Unknown Extended Service(%d)",
+ yaz_log (YLOG_WARN, "Unknown Extended Service(%d)",
rr->esr->taskSpecificParameters->which);
}