2 * Copyright (C) 1995-1998, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1999-06-08 10:10:16 adam
8 * New sub directory zutil. Moved YAZ Compiler to be part of YAZ tree.
10 * Revision 1.1 1998/11/16 16:02:35 adam
11 * Added loggin utilies, log_rpn_query and log_scan_term. These used
12 * to be part of Zebra.
16 * Old logs from zlogs.c:
18 * Revision 1.9 1998/10/13 20:36:02 adam
19 * Changed "indent" format string in log messages.
21 * Revision 1.8 1998/04/02 14:35:29 adam
22 * First version of Zebra that works with compiled ASN.1.
24 * Revision 1.7 1998/01/29 13:40:11 adam
25 * Better logging for scan service.
27 * Revision 1.6 1997/09/29 09:06:41 adam
28 * Removed static var to make this module thread safe.
30 * Revision 1.5 1997/04/30 08:56:07 quinn
33 * Revision 1.4 1996/10/08 09:41:25 quinn
36 * Revision 1.3 1996/03/20 09:36:40 adam
37 * Function dict_lookup_grep got extra parameter, init_pos, which marks
38 * from which position in pattern approximate pattern matching should occur.
39 * Approximate pattern matching is used in relevance=re-2.
41 * Revision 1.2 1996/01/03 16:22:11 quinn
44 * Revision 1.1 1995/11/16 17:00:55 adam
45 * Better logging of rpn query.
54 static void attrStr (int type, int value, enum oid_value ast, char *str)
71 sprintf (str, "relation=Less than");
74 sprintf (str, "relation=Less than or equal");
77 sprintf (str, "relation=Equal");
80 sprintf (str, "relation=Greater or equal");
83 sprintf (str, "relation=Greater than");
86 sprintf (str, "relation=Not equal");
89 sprintf (str, "relation=Phonetic");
92 sprintf (str, "relation=Stem");
95 sprintf (str, "relation=Relevance");
98 sprintf (str, "relation=AlwaysMatches");
101 sprintf (str, "relation");
108 sprintf (str, "position=First in field");
111 sprintf (str, "position=First in any subfield");
114 sprintf (str, "position=Any position in field");
117 sprintf (str, "position");
124 sprintf (str, "structure=Phrase");
127 sprintf (str, "structure=Word");
130 sprintf (str, "structure=Key");
133 sprintf (str, "structure=Year");
136 sprintf (str, "structure=Date");
139 sprintf (str, "structure=Word list");
142 sprintf (str, "structure=Date (un)");
145 sprintf (str, "structure=Name (norm)");
148 sprintf (str, "structure=Name (un)");
151 sprintf (str, "structure=Structure");
154 sprintf (str, "structure=urx");
157 sprintf (str, "structure=free-form-text");
160 sprintf (str, "structure=document-text");
163 sprintf (str, "structure=local-number");
166 sprintf (str, "structure=string");
169 sprintf (str, "structure=numeric string");
172 sprintf (str, "structure");
179 sprintf (str, "truncation=Right");
182 sprintf (str, "truncation=Left");
185 sprintf (str, "truncation=Left&right");
188 sprintf (str, "truncation=Do not truncate");
191 sprintf (str, "truncation=Process #");
194 sprintf (str, "truncation=re-1");
197 sprintf (str, "truncation=re-2");
200 sprintf (str, "truncation");
207 sprintf (str, "completeness=Incomplete subfield");
210 sprintf (str, "completeness=Complete subfield");
213 sprintf (str, "completeness=Complete field");
216 sprintf (str, "completeness");
225 sprintf (str + strlen(str), " (%d=%d)", type, value);
227 sprintf (str, "%d=%d", type, value);
231 * zlog_attributes: print attributes of term
233 static void zlog_attributes (Z_AttributesPlusTerm *t, int level,
239 int num_attributes = t->attributes->num_attributes;
241 int num_attributes = t->num_attributes;
244 for (of = 0; of < num_attributes; of++)
246 const char *attset_name = "";
247 Z_AttributeElement *element;
249 element = t->attributes->attributes[of];
251 element = t->attributeList[of];
253 if (element->attributeSet)
256 attrset = oid_getentbyoid (element->attributeSet);
257 attset_name = attrset->desc;
259 switch (element->which)
261 case Z_AttributeValue_numeric:
262 attrStr (*element->attributeType,
263 *element->value.numeric, ast, str);
264 logf (LOG_LOG, "%*.0s%s %s", level, "", attset_name, str);
266 case Z_AttributeValue_complex:
267 logf (LOG_LOG, "%*.0s%s attributeType=%d complex",
268 level, "", attset_name, *element->attributeType);
269 for (i = 0; i<element->value.complex->num_list; i++)
271 if (element->value.complex->list[i]->which ==
272 Z_StringOrNumeric_string)
273 logf (LOG_LOG, "%*.0s string: '%s'", level, "",
274 element->value.complex->list[i]->u.string);
275 else if (element->value.complex->list[i]->which ==
276 Z_StringOrNumeric_numeric)
277 logf (LOG_LOG, "%*.0s numeric: '%d'", level, "",
278 *element->value.complex->list[i]->u.numeric);
282 logf (LOG_LOG, "%.*s%s attribute unknown",
283 level, "", attset_name);
288 static void zlog_structure (Z_RPNStructure *zs, int level, enum oid_value ast)
290 if (zs->which == Z_RPNStructure_complex)
292 switch (zs->u.complex->roperator->which)
295 logf (LOG_LOG, "%*.0s and", level, "");
298 logf (LOG_LOG, "%*.0s or", level, "");
300 case Z_Operator_and_not:
301 logf (LOG_LOG, "%*.0s and-not", level, "");
304 logf (LOG_LOG, "%*.0s unknown complex", level, "");
307 zlog_structure (zs->u.complex->s1, level+2, ast);
308 zlog_structure (zs->u.complex->s2, level+2, ast);
310 else if (zs->which == Z_RPNStructure_simple)
312 if (zs->u.simple->which == Z_Operand_APT)
314 Z_AttributesPlusTerm *zapt = zs->u.simple->u.attributesPlusTerm;
316 if (zapt->term->which == Z_Term_general)
318 logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
319 zapt->term->u.general->len, zapt->term->u.general->buf);
323 logf (LOG_LOG, "%*.0s term (not general)", level, "");
325 zlog_attributes (zapt, level+2, ast);
327 else if (zs->u.simple->which == Z_Operand_resultSetId)
329 logf (LOG_LOG, "%*.0s set '%s'", level, "",
330 zs->u.simple->u.resultSetId);
333 logf (LOG_LOG, "%*.0s unknown simple structure", level, "");
336 logf (LOG_LOG, "%*.0s unknown structure", level, "");
339 void log_rpn_query (Z_RPNQuery *rpn)
344 attrset = oid_getentbyoid (rpn->attributeSetId);
347 ast = attrset->value;
348 logf (LOG_LOG, "RPN query. Type: %s", attrset->desc);
353 logf (LOG_LOG, "RPN query. Unknown type");
355 zlog_structure (rpn->RPNStructure, 0, ast);
358 void log_scan_term (Z_AttributesPlusTerm *zapt, oid_value ast)
361 if (zapt->term->which == Z_Term_general)
363 logf (LOG_LOG, "%*.0s term '%.*s' (general)", level, "",
364 zapt->term->u.general->len, zapt->term->u.general->buf);
367 logf (LOG_LOG, "%*.0s term (not general)", level, "");
368 zlog_attributes (zapt, level+2, ast);