{
if (i == SESSION_MAX_TERMLISTS)
{
- yaz_log(YLOG_FATAL, "Too many termlists");
+ session_log(s, YLOG_FATAL, "Too many termlists");
return;
}
= termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
s->num_termlists = i + 1;
}
- yaz_log(YLOG_DEBUG, "Session: facets for %s: %s (%d)", type, value, count);
+ session_log(s, YLOG_DEBUG, "Session: facets for %s: %s (%d)",
+ type, value, count);
termlist_insert(s->termlists[i].termlist, value, count);
}
-static xmlDoc *record_to_xml(struct session_database *sdb, const char *rec)
+static xmlDoc *record_to_xml(struct session *se,
+ struct session_database *sdb, const char *rec)
{
struct database *db = sdb->database;
xmlDoc *rdoc = 0;
if (!rdoc)
{
- yaz_log(YLOG_FATAL, "Non-wellformed XML received from %s",
- db->url);
+ session_log(se, YLOG_FATAL, "Non-wellformed XML received from %s",
+ db->url);
return 0;
}
if (global_parameters.dump_records)
{
- yaz_log(YLOG_LOG, "Un-normalized record from %s", db->url);
+ session_log(se, YLOG_LOG, "Un-normalized record from %s", db->url);
log_xml_doc(rdoc);
}
}
}
-static xmlDoc *normalize_record(struct session_database *sdb,
+static xmlDoc *normalize_record(struct session *se,
+ struct session_database *sdb,
struct conf_service *service,
const char *rec, NMEM nmem)
{
- xmlDoc *rdoc = record_to_xml(sdb, rec);
+ xmlDoc *rdoc = record_to_xml(se, sdb, rec);
if (rdoc)
{
if (normalize_record_transform(sdb->map, &rdoc, (const char **)parms))
{
- yaz_log(YLOG_WARN, "Normalize failed from %s", sdb->database->url);
+ session_log(se, YLOG_WARN, "Normalize failed from %s",
+ sdb->database->url);
}
else
{
if (global_parameters.dump_records)
{
- yaz_log(YLOG_LOG, "Normalized record from %s",
- sdb->database->url);
+ session_log(se, YLOG_LOG, "Normalized record from %s",
+ sdb->database->url);
log_xml_doc(rdoc);
}
}
if (!sdb->settings)
{
- yaz_log(YLOG_WARN, "No settings on %s", sdb->database->url);
+ session_log(se, YLOG_WARN, "No settings on %s", sdb->database->url);
return -1;
}
if ((s = session_setting_oneval(sdb, PZ_XSLT)))
}
else
{
- yaz_log(YLOG_WARN, "No pz:requestsyntax for auto stylesheet");
+ session_log(se, YLOG_WARN,
+ "No pz:requestsyntax for auto stylesheet");
}
}
sdb->map = normalize_cache_get(se->normalize_cache,
{
if (!sdb->settings)
{
- yaz_log(YLOG_WARN,
+ session_log(se, YLOG_WARN,
"No settings associated with %s", sdb->database->url);
return -1;
}
s->watchlist[what].obs = 0;
session_leave(s);
- yaz_log(YLOG_DEBUG, "session_alert_watch: %d calling function: %p", what, fun);
+ session_log(s, YLOG_DEBUG,
+ "session_alert_watch: %d calling function: %p", what, fun);
fun(data);
}
else
for (l = s->clients; l; l = l->next)
if (client_is_active_preferred(l->client))
res++;
- yaz_log(YLOG_DEBUG, "%p Session has %d active preferred clients.", s, res);
+ session_log(s, YLOG_DEBUG, "Session has %d active preferred clients.", res);
return res == 0;
}
struct client_list *l;
struct timeval tval;
- yaz_log(YLOG_DEBUG, "Search");
+ session_log(se, YLOG_DEBUG, "Search");
*addinfo = 0;
{
struct session_database *sdb;
- yaz_log(YLOG_DEBUG, "%p Pazpar2 session destroy", se);
+ session_log(se, YLOG_DEBUG, "Pazpar2 session destroy");
session_remove_clients(se);
for (sdb = se->databases; sdb; sdb = sdb->next)
}
struct session *new_session(NMEM nmem, struct conf_service *service,
- const char *name)
+ unsigned session_id)
{
int i;
struct session *session = nmem_malloc(nmem, sizeof(*session));
- yaz_log(YLOG_DEBUG, "%p New Pazpar2 session", session);
+ char tmp_str[50];
+
+ sprintf(tmp_str, "session#%u", session_id);
+ session->session_id = session_id;
+ session_log(session, YLOG_DEBUG, "New session");
session->service = service;
session->relevance = 0;
session->total_hits = 0;
}
session->normalize_cache = normalize_cache_create();
session->session_mutex = 0;
- pazpar2_mutex_create(&session->session_mutex, name);
+ pazpar2_mutex_create(&session->session_mutex, tmp_str);
return session;
}
int ret = 0;
struct session_database *sdb = client_get_database(cl);
struct conf_service *service = se->service;
- xmlDoc *xdoc = normalize_record(sdb, service, rec, nmem);
+ xmlDoc *xdoc = normalize_record(se, sdb, service, rec, nmem);
xmlNode *root;
const char *mergekey_norm;
if (!check_record_filter(root, sdb))
{
- yaz_log(YLOG_WARN, "Filtered out record no %d from %s", record_no,
- sdb->database->url);
+ session_log(se, YLOG_WARN, "Filtered out record no %d from %s",
+ record_no, sdb->database->url);
xmlFreeDoc(xdoc);
return -1;
}
mergekey_norm = get_mergekey(xdoc, cl, record_no, service, nmem);
if (!mergekey_norm)
{
- yaz_log(YLOG_WARN, "Got no mergekey");
+ session_log(se, YLOG_WARN, "Got no mergekey");
xmlFreeDoc(xdoc);
return -1;
}
if (!cluster)
return -1;
if (global_parameters.dump_records)
- yaz_log(YLOG_LOG, "Cluster id %s from %s (#%d)", cluster->recid,
- sdb->database->url, record_no);
+ session_log(se, YLOG_LOG, "Cluster id %s from %s (#%d)", cluster->recid,
+ sdb->database->url, record_no);
relevance_newrec(se->relevance, cluster);
// now parsing XML record and adding data to cluster or record metadata
{
if (se->number_of_warnings_unknown_metadata == 0)
{
- yaz_log(YLOG_WARN,
+ session_log(se, YLOG_WARN,
"Ignoring unknown metadata element: %s", type);
}
se->number_of_warnings_unknown_metadata++;
ser_md->type, n->properties);
if (!rec_md)
{
- yaz_log(YLOG_WARN, "bad metadata data '%s' for element '%s'",
- value, type);
+ session_log(se, YLOG_WARN, "bad metadata data '%s' "
+ "for element '%s'", value, type);
continue;
}
wheretoput = &record->metadata[md_field_id];
if (!sort_str)
{
sort_str = rec_md->data.text.disp;
- yaz_log(YLOG_WARN,
+ session_log(se, YLOG_WARN,
"Could not make sortkey. Bug #1858");
}
cluster->sortkeys[sk_field_id]->text.sort =
nmem_strdup(se->nmem, sort_str);
-#if 0
- yaz_log(YLOG_LOG, "text disp=%s",
- cluster->sortkeys[sk_field_id]->text.disp);
- yaz_log(YLOG_LOG, "text sort=%s",
- cluster->sortkeys[sk_field_id]->text.sort);
-#endif
pp2_relevance_token_destroy(prt);
}
}
else
{
if (se->number_of_warnings_unknown_elements == 0)
- yaz_log(YLOG_WARN,
+ session_log(se, YLOG_WARN,
"Unexpected element in internal record: %s", n->name);
se->number_of_warnings_unknown_elements++;
}
return 0;
}
+void session_log(struct session *s, int level, const char *fmt, ...)
+{
+ char buf[1024];
+ va_list ap;
+ va_start(ap, fmt);
+
+ yaz_vsnprintf(buf, sizeof(buf)-30, fmt, ap);
+ yaz_log(level, "%u %s", s->session_id, buf);
+
+ va_end(ap);
+}
+
/*
* Local variables:
* c-basic-offset: 4