+
+ 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 tid[TID_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, " ");
+ tid[0] = '\0';
+
+ if (l_level & YLOG_TID)
+ {
+ yaz_thread_id_cstr(tid, sizeof(tid)-1);
+ if (tid[0])
+ strcat(tid, " ");
+ }
+
+ fprintf(file, "%s%s%s%s %s", tbuf, yaz_log_info.l_prefix,
+ tid, flags, yaz_log_info.l_prefix2);
+ vfprintf(file, fmt, ap);
+ if (error_cp)
+ fprintf(file, " [%s]", error_cp);
+ fputs("\n", file);
+ if (l_level & YLOG_FLUSH)
+ fflush(file);
+ }
+ yaz_log_unlock();
+}
+
+void yaz_log(int level, const char *fmt, ...)
+{
+ va_list ap;
+ FILE *file;
+ int o_level = level;
+ char *error_cp = 0, error_buf[128];
+