+
+ yaz_log_open_check(tm, 0, "a");
+ file = yaz_log_file(); /* file may change in yaz_log_open_check */
+
+ if (file)
+ {
+ char tbuf[TIMEFORMAT_LEN];
+ char flags[1024];
+ int i;
+
+ *flags = '\0';
+ for (i = 0; level && mask_names[i].name; i++)
+ if ( mask_names[i].mask & level)
+ {
+ if (*mask_names[i].name && mask_names[i].mask &&
+ mask_names[i].mask != YLOG_ALL)
+ {
+ if (strlen(flags) + strlen(mask_names[i].name)
+ < sizeof(flags) - 4)
+ {
+ strcat(flags, "[");
+ strcat(flags, mask_names[i].name);
+ strcat(flags, "]");
+ }
+ level &= ~mask_names[i].mask;
+ }
+ }
+
+ tbuf[0] = '\0';
+ if (!(l_level & YLOG_NOTIME))
+ {
+ yaz_strftime(tbuf, TIMEFORMAT_LEN-2, l_actual_format, tm);
+ tbuf[TIMEFORMAT_LEN-2] = '\0';
+ }
+ if (tbuf[0])
+ strcat(tbuf, " ");
+ fprintf(file, "%s%s%s %s%s\n", tbuf, l_prefix, flags, l_prefix2,
+ log_message);
+ if (l_level & YLOG_FLUSH)
+ fflush(file);
+ }
+}
+
+void yaz_log(int level, const char *fmt, ...)
+{
+ va_list ap;
+ char buf[4096];
+ FILE *file;
+ int o_level = level;
+
+ internal_log_init();
+ if (!(level & l_level))
+ return;
+ va_start(ap, fmt);
+
+ /* 30 is enough for our 'rest of output' message */
+ yaz_vsnprintf(buf, sizeof(buf)-30, fmt, ap);
+ if (strlen(buf) >= sizeof(buf)-31)
+ strcat(buf, " [rest of output omitted]");
+
+ if (o_level & YLOG_ERRNO)