[PATCH v4 5/7] Introduce _notmuch_message_has_term()
[notmuch-archives.git] / 2a / 648be6025422ce3ad3f9b046010397e03b9ca5
1 Return-Path: <bremner@tesseract.cs.unb.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 00B0C429E2F\r
6         for <notmuch@notmuchmail.org>; Fri, 26 Dec 2014 09:43:34 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id GzYdMpBVfNUu for <notmuch@notmuchmail.org>;\r
16         Fri, 26 Dec 2014 09:43:27 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 0AD6A429E26\r
21         for <notmuch@notmuchmail.org>; Fri, 26 Dec 2014 09:43:26 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <bremner@tesseract.cs.unb.ca>)\r
24         id 1Y4Yv7-000604-DA; Fri, 26 Dec 2014 13:43:25 -0400\r
25 Received: (nullmailer pid 21758 invoked by uid 1000); Fri, 26 Dec 2014\r
26         17:43:08 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: notmuch@notmuchmail.org\r
29 Subject: [PATCH 3/4] lib: replace almost all fprintfs in library with n_d_log\r
30 Date: Fri, 26 Dec 2014 18:42:40 +0100\r
31 Message-Id: <1419615761-21581-4-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 2.1.3\r
33 In-Reply-To: <1419615761-21581-1-git-send-email-david@tethera.net>\r
34 References: <1419615761-21581-1-git-send-email-david@tethera.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.13\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39         <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Fri, 26 Dec 2014 17:43:35 -0000\r
48 \r
49 This is not supposed to change any functionality from an end user\r
50 point of view. The remaining fprintf will need an internal API change.\r
51 ---\r
52  lib/database.cc  | 56 ++++++++++++++++++++++++++++----------------------------\r
53  lib/directory.cc |  4 ++--\r
54  lib/index.cc     | 11 +++++++----\r
55  lib/message.cc   |  6 +++---\r
56  lib/query.cc     | 18 +++++++++---------\r
57  5 files changed, 49 insertions(+), 46 deletions(-)\r
58 \r
59 diff --git a/lib/database.cc b/lib/database.cc\r
60 index f3c62ee..8143758 100644\r
61 --- a/lib/database.cc\r
62 +++ b/lib/database.cc\r
63 @@ -450,7 +450,7 @@ notmuch_database_find_message (notmuch_database_t *notmuch,\r
64  \r
65         return NOTMUCH_STATUS_SUCCESS;\r
66      } catch (const Xapian::Error &error) {\r
67 -       fprintf (stderr, "A Xapian exception occurred finding message: %s.\n",\r
68 +       notmuch_database_log (notmuch, "A Xapian exception occurred finding message: %s.\n",\r
69                  error.get_msg().c_str());\r
70         notmuch->exception_reported = TRUE;\r
71         *message_ret = NULL;\r
72 @@ -609,21 +609,21 @@ notmuch_database_create (const char *path, notmuch_database_t **database)\r
73      int err;\r
74  \r
75      if (path == NULL) {\r
76 -       fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");\r
77 +       notmuch_database_log (notmuch, "Error: Cannot create a database for a NULL path.\n");\r
78         status = NOTMUCH_STATUS_NULL_POINTER;\r
79         goto DONE;\r
80      }\r
81  \r
82      err = stat (path, &st);\r
83      if (err) {\r
84 -       fprintf (stderr, "Error: Cannot create database at %s: %s.\n",\r
85 +       notmuch_database_log (notmuch, "Error: Cannot create database at %s: %s.\n",\r
86                  path, strerror (errno));\r
87         status = NOTMUCH_STATUS_FILE_ERROR;\r
88         goto DONE;\r
89      }\r
90  \r
91      if (! S_ISDIR (st.st_mode)) {\r
92 -       fprintf (stderr, "Error: Cannot create database at %s: Not a directory.\n",\r
93 +       notmuch_database_log (notmuch, "Error: Cannot create database at %s: Not a directory.\n",\r
94                  path);\r
95         status = NOTMUCH_STATUS_FILE_ERROR;\r
96         goto DONE;\r
97 @@ -634,7 +634,7 @@ notmuch_database_create (const char *path, notmuch_database_t **database)\r
98      err = mkdir (notmuch_path, 0755);\r
99  \r
100      if (err) {\r
101 -       fprintf (stderr, "Error: Cannot create directory %s: %s.\n",\r
102 +       notmuch_database_log (notmuch, "Error: Cannot create directory %s: %s.\n",\r
103                  notmuch_path, strerror (errno));\r
104         status = NOTMUCH_STATUS_FILE_ERROR;\r
105         goto DONE;\r
106 @@ -671,7 +671,7 @@ notmuch_status_t\r
107  _notmuch_database_ensure_writable (notmuch_database_t *notmuch)\r
108  {\r
109      if (notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY) {\r
110 -       fprintf (stderr, "Cannot write to a read-only database.\n");\r
111 +       notmuch_database_log (notmuch, "Cannot write to a read-only database.\n");\r
112         return NOTMUCH_STATUS_READ_ONLY_DATABASE;\r
113      }\r
114  \r
115 @@ -770,27 +770,27 @@ notmuch_database_open (const char *path,\r
116      static int initialized = 0;\r
117  \r
118      if (path == NULL) {\r
119 -       fprintf (stderr, "Error: Cannot open a database for a NULL path.\n");\r
120 +       notmuch_database_log (notmuch, "Error: Cannot open a database for a NULL path.\n");\r
121         status = NOTMUCH_STATUS_NULL_POINTER;\r
122         goto DONE;\r
123      }\r
124  \r
125      if (! (notmuch_path = talloc_asprintf (local, "%s/%s", path, ".notmuch"))) {\r
126 -       fprintf (stderr, "Out of memory\n");\r
127 +       notmuch_database_log (notmuch, "Out of memory\n");\r
128         status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
129         goto DONE;\r
130      }\r
131  \r
132      err = stat (notmuch_path, &st);\r
133      if (err) {\r
134 -       fprintf (stderr, "Error opening database at %s: %s\n",\r
135 +       notmuch_database_log (notmuch, "Error opening database at %s: %s\n",\r
136                  notmuch_path, strerror (errno));\r
137         status = NOTMUCH_STATUS_FILE_ERROR;\r
138         goto DONE;\r
139      }\r
140  \r
141      if (! (xapian_path = talloc_asprintf (local, "%s/%s", notmuch_path, "xapian"))) {\r
142 -       fprintf (stderr, "Out of memory\n");\r
143 +       notmuch_database_log (notmuch, "Out of memory\n");\r
144         status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
145         goto DONE;\r
146      }\r
147 @@ -830,7 +830,7 @@ notmuch_database_open (const char *path,\r
148          * means a dramatically incompatible change. */\r
149         version = notmuch_database_get_version (notmuch);\r
150         if (version > NOTMUCH_DATABASE_VERSION) {\r
151 -           fprintf (stderr,\r
152 +           notmuch_database_log (notmuch,\r
153                      "Error: Notmuch database at %s\n"\r
154                      "       has a newer database format version (%u) than supported by this\n"\r
155                      "       version of notmuch (%u).\n",\r
156 @@ -849,7 +849,7 @@ notmuch_database_open (const char *path,\r
157             version, mode == NOTMUCH_DATABASE_MODE_READ_WRITE ? 'w' : 'r',\r
158             &incompat_features);\r
159         if (incompat_features) {\r
160 -           fprintf (stderr,\r
161 +           notmuch_database_log (notmuch,\r
162                      "Error: Notmuch database at %s\n"\r
163                      "       requires features (%s)\n"\r
164                      "       not supported by this version of notmuch.\n",\r
165 @@ -899,7 +899,7 @@ notmuch_database_open (const char *path,\r
166             notmuch->query_parser->add_prefix (prefix->name, prefix->prefix);\r
167         }\r
168      } catch (const Xapian::Error &error) {\r
169 -       fprintf (stderr, "A Xapian exception occurred opening database: %s\n",\r
170 +       notmuch_database_log (notmuch, "A Xapian exception occurred opening database: %s\n",\r
171                  error.get_msg().c_str());\r
172         notmuch_database_destroy (notmuch);\r
173         notmuch = NULL;\r
174 @@ -961,7 +961,7 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
175         } catch (const Xapian::Error &error) {\r
176             status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
177             if (! notmuch->exception_reported) {\r
178 -               fprintf (stderr, "Error: A Xapian exception occurred closing database: %s\n",\r
179 +               notmuch_database_log (notmuch, "Error: A Xapian exception occurred closing database: %s\n",\r
180                          error.get_msg().c_str());\r
181             }\r
182         }\r
183 @@ -1088,12 +1088,12 @@ notmuch_database_compact (const char *path,\r
184      }\r
185  \r
186      if (stat (backup_path, &statbuf) != -1) {\r
187 -       fprintf (stderr, "Path already exists: %s\n", backup_path);\r
188 +       notmuch_database_log (notmuch, "Path already exists: %s\n", backup_path);\r
189         ret = NOTMUCH_STATUS_FILE_ERROR;\r
190         goto DONE;\r
191      }\r
192      if (errno != ENOENT) {\r
193 -       fprintf (stderr, "Unknown error while stat()ing path: %s\n",\r
194 +       notmuch_database_log (notmuch, "Unknown error while stat()ing path: %s\n",\r
195                  strerror (errno));\r
196         ret = NOTMUCH_STATUS_FILE_ERROR;\r
197         goto DONE;\r
198 @@ -1113,20 +1113,20 @@ notmuch_database_compact (const char *path,\r
199         compactor.set_destdir (compact_xapian_path);\r
200         compactor.compact ();\r
201      } catch (const Xapian::Error &error) {\r
202 -       fprintf (stderr, "Error while compacting: %s\n", error.get_msg().c_str());\r
203 +       notmuch_database_log (notmuch, "Error while compacting: %s\n", error.get_msg().c_str());\r
204         ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
205         goto DONE;\r
206      }\r
207  \r
208      if (rename (xapian_path, backup_path)) {\r
209 -       fprintf (stderr, "Error moving %s to %s: %s\n",\r
210 +       notmuch_database_log (notmuch, "Error moving %s to %s: %s\n",\r
211                  xapian_path, backup_path, strerror (errno));\r
212         ret = NOTMUCH_STATUS_FILE_ERROR;\r
213         goto DONE;\r
214      }\r
215  \r
216      if (rename (compact_xapian_path, xapian_path)) {\r
217 -       fprintf (stderr, "Error moving %s to %s: %s\n",\r
218 +       notmuch_database_log (notmuch, "Error moving %s to %s: %s\n",\r
219                  compact_xapian_path, xapian_path, strerror (errno));\r
220         ret = NOTMUCH_STATUS_FILE_ERROR;\r
221         goto DONE;\r
222 @@ -1134,7 +1134,7 @@ notmuch_database_compact (const char *path,\r
223  \r
224      if (! keep_backup) {\r
225         if (rmtree (backup_path)) {\r
226 -           fprintf (stderr, "Error removing old database %s: %s\n",\r
227 +           notmuch_database_log (notmuch, "Error removing old database %s: %s\n",\r
228                      backup_path, strerror (errno));\r
229             ret = NOTMUCH_STATUS_FILE_ERROR;\r
230             goto DONE;\r
231 @@ -1163,7 +1163,7 @@ notmuch_database_compact (unused (const char *path),\r
232                           unused (notmuch_compact_status_cb_t status_cb),\r
233                           unused (void *closure))\r
234  {\r
235 -    fprintf (stderr, "notmuch was compiled against a xapian version lacking compaction support.\n");\r
236 +    notmuch_database_log (notmuch, "notmuch was compiled against a xapian version lacking compaction support.\n");\r
237      return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;\r
238  }\r
239  #endif\r
240 @@ -1441,7 +1441,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,\r
241             }\r
242  \r
243             if (private_status) {\r
244 -               fprintf (stderr,\r
245 +               notmuch_database_log (notmuch,\r
246                          "Upgrade failed while creating ghost messages.\n");\r
247                 status = COERCE_STATUS (private_status, "Unexpected status from _notmuch_message_initialize_ghost");\r
248                 goto DONE;\r
249 @@ -1491,7 +1491,7 @@ notmuch_database_begin_atomic (notmuch_database_t *notmuch)\r
250      try {\r
251         (static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db))->begin_transaction (false);\r
252      } catch (const Xapian::Error &error) {\r
253 -       fprintf (stderr, "A Xapian exception occurred beginning transaction: %s.\n",\r
254 +       notmuch_database_log (notmuch, "A Xapian exception occurred beginning transaction: %s.\n",\r
255                  error.get_msg().c_str());\r
256         notmuch->exception_reported = TRUE;\r
257         return NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
258 @@ -1525,7 +1525,7 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch)\r
259         if (thresh && atoi (thresh) == 1)\r
260             db->flush ();\r
261      } catch (const Xapian::Error &error) {\r
262 -       fprintf (stderr, "A Xapian exception occurred committing transaction: %s.\n",\r
263 +       notmuch_database_log (notmuch, "A Xapian exception occurred committing transaction: %s.\n",\r
264                  error.get_msg().c_str());\r
265         notmuch->exception_reported = TRUE;\r
266         return NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
267 @@ -1771,7 +1771,7 @@ notmuch_database_get_directory (notmuch_database_t *notmuch,\r
268         *directory = _notmuch_directory_create (notmuch, path,\r
269                                                 NOTMUCH_FIND_LOOKUP, &status);\r
270      } catch (const Xapian::Error &error) {\r
271 -       fprintf (stderr, "A Xapian exception occurred getting directory: %s.\n",\r
272 +       notmuch_database_log (notmuch, "A Xapian exception occurred getting directory: %s.\n",\r
273                  error.get_msg().c_str());\r
274         notmuch->exception_reported = TRUE;\r
275         status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
276 @@ -2353,7 +2353,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,\r
277  \r
278         _notmuch_message_sync (message);\r
279      } catch (const Xapian::Error &error) {\r
280 -       fprintf (stderr, "A Xapian exception occurred adding message: %s.\n",\r
281 +       notmuch_database_log (notmuch, "A Xapian exception occurred adding message: %s.\n",\r
282                  error.get_msg().c_str());\r
283         notmuch->exception_reported = TRUE;\r
284         ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
285 @@ -2445,7 +2445,7 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,\r
286                 status = NOTMUCH_STATUS_OUT_OF_MEMORY;\r
287         }\r
288      } catch (const Xapian::Error &error) {\r
289 -       fprintf (stderr, "Error: A Xapian exception occurred finding message by filename: %s\n",\r
290 +       notmuch_database_log (notmuch, "Error: A Xapian exception occurred finding message by filename: %s\n",\r
291                  error.get_msg().c_str());\r
292         notmuch->exception_reported = TRUE;\r
293         status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
294 @@ -2498,7 +2498,7 @@ notmuch_database_get_all_tags (notmuch_database_t *db)\r
295         _notmuch_string_list_sort (tags);\r
296         return _notmuch_tags_create (db, tags);\r
297      } catch (const Xapian::Error &error) {\r
298 -       fprintf (stderr, "A Xapian exception occurred getting tags: %s.\n",\r
299 +       notmuch_database_log (db, "A Xapian exception occurred getting tags: %s.\n",\r
300                  error.get_msg().c_str());\r
301         db->exception_reported = TRUE;\r
302         return NULL;\r
303 diff --git a/lib/directory.cc b/lib/directory.cc\r
304 index 8daaec8..955ffac 100644\r
305 --- a/lib/directory.cc\r
306 +++ b/lib/directory.cc\r
307 @@ -186,7 +186,7 @@ _notmuch_directory_create (notmuch_database_t *notmuch,\r
308         directory->mtime = Xapian::sortable_unserialise (\r
309             directory->doc.get_value (NOTMUCH_VALUE_TIMESTAMP));\r
310      } catch (const Xapian::Error &error) {\r
311 -       fprintf (stderr,\r
312 +       notmuch_database_log (notmuch,\r
313                  "A Xapian exception occurred creating a directory: %s.\n",\r
314                  error.get_msg().c_str());\r
315         notmuch->exception_reported = TRUE;\r
316 @@ -228,7 +228,7 @@ notmuch_directory_set_mtime (notmuch_directory_t *directory,\r
317  \r
318         db->replace_document (directory->document_id, directory->doc);\r
319      } catch (const Xapian::Error &error) {\r
320 -       fprintf (stderr,\r
321 +       notmuch_database_log (notmuch,\r
322                  "A Xapian exception occurred setting directory mtime: %s.\n",\r
323                  error.get_msg().c_str());\r
324         notmuch->exception_reported = TRUE;\r
325 diff --git a/lib/index.cc b/lib/index.cc\r
326 index 1a2e63d..8fce9b8 100644\r
327 --- a/lib/index.cc\r
328 +++ b/lib/index.cc\r
329 @@ -314,7 +314,8 @@ _index_mime_part (notmuch_message_t *message,\r
330      const char *charset;\r
331  \r
332      if (! part) {\r
333 -       fprintf (stderr, "Warning: Not indexing empty mime part.\n");\r
334 +       notmuch_database_log (_notmuch_message_database (message),\r
335 +                             "Warning: Not indexing empty mime part.\n");\r
336         return;\r
337      }\r
338  \r
339 @@ -334,7 +335,8 @@ _index_mime_part (notmuch_message_t *message,\r
340                 if (i == 1)\r
341                     continue;\r
342                 if (i > 1)\r
343 -                   fprintf (stderr, "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
344 +                   notmuch_database_log (_notmuch_message_database (message),\r
345 +                                         "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");\r
346             }\r
347             if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {\r
348                 /* Don't index encrypted parts. */\r
349 @@ -357,8 +359,9 @@ _index_mime_part (notmuch_message_t *message,\r
350      }\r
351  \r
352      if (! (GMIME_IS_PART (part))) {\r
353 -       fprintf (stderr, "Warning: Not indexing unknown mime part: %s.\n",\r
354 -                g_type_name (G_OBJECT_TYPE (part)));\r
355 +       notmuch_database_log (_notmuch_message_database (message),\r
356 +                             "Warning: Not indexing unknown mime part: %s.\n",\r
357 +                             g_type_name (G_OBJECT_TYPE (part)));\r
358         return;\r
359      }\r
360  \r
361 diff --git a/lib/message.cc b/lib/message.cc\r
362 index 43cc078..60601ef 100644\r
363 --- a/lib/message.cc\r
364 +++ b/lib/message.cc\r
365 @@ -252,7 +252,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,\r
366  \r
367         doc_id = _notmuch_database_generate_doc_id (notmuch);\r
368      } catch (const Xapian::Error &error) {\r
369 -       fprintf (stderr, "A Xapian exception occurred creating message: %s\n",\r
370 +       notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n",\r
371                  error.get_msg().c_str());\r
372         notmuch->exception_reported = TRUE;\r
373         *status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;\r
374 @@ -467,7 +467,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)\r
375                 return talloc_strdup (message, value.c_str ());\r
376  \r
377         } catch (Xapian::Error &error) {\r
378 -           fprintf (stderr, "A Xapian exception occurred when reading header: %s\n",\r
379 +           notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading header: %s\n",\r
380                      error.get_msg().c_str());\r
381             message->notmuch->exception_reported = TRUE;\r
382             return NULL;\r
383 @@ -920,7 +920,7 @@ notmuch_message_get_date (notmuch_message_t *message)\r
384      try {\r
385         value = message->doc.get_value (NOTMUCH_VALUE_TIMESTAMP);\r
386      } catch (Xapian::Error &error) {\r
387 -       fprintf (stderr, "A Xapian exception occurred when reading date: %s\n",\r
388 +       notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading date: %s\n",\r
389                  error.get_msg().c_str());\r
390         message->notmuch->exception_reported = TRUE;\r
391         return 0;\r
392 diff --git a/lib/query.cc b/lib/query.cc\r
393 index 60ff8bd..677b130 100644\r
394 --- a/lib/query.cc\r
395 +++ b/lib/query.cc\r
396 @@ -78,7 +78,7 @@ notmuch_query_create (notmuch_database_t *notmuch,\r
397      notmuch_query_t *query;\r
398  \r
399      if (_debug_query ())\r
400 -       fprintf (stderr, "Query string is:\n%s\n", query_string);\r
401 +       notmuch_database_log (notmuch, "Query string is:\n%s\n", query_string);\r
402  \r
403      query = talloc (notmuch, notmuch_query_t);\r
404      if (unlikely (query == NULL))\r
405 @@ -266,9 +266,9 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
406         }\r
407  \r
408         if (_debug_query ()) {\r
409 -           fprintf (stderr, "Exclude query is:\n%s\n",\r
410 +           notmuch_database_log (notmuch, "Exclude query is:\n%s\n",\r
411                      exclude_query.get_description ().c_str ());\r
412 -           fprintf (stderr, "Final query is:\n%s\n",\r
413 +           notmuch_database_log (notmuch, "Final query is:\n%s\n",\r
414                      final_query.get_description ().c_str ());\r
415         }\r
416  \r
417 @@ -282,9 +282,9 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
418         return &messages->base;\r
419  \r
420      } catch (const Xapian::Error &error) {\r
421 -       fprintf (stderr, "A Xapian exception occurred performing query: %s\n",\r
422 +       notmuch_database_log (notmuch, "A Xapian exception occurred performing query: %s\n",\r
423                  error.get_msg().c_str());\r
424 -       fprintf (stderr, "Query string was: %s\n", query->query_string);\r
425 +       notmuch_database_log (notmuch, "Query string was: %s\n", query->query_string);\r
426         notmuch->exception_reported = TRUE;\r
427         talloc_free (messages);\r
428         return NULL;\r
429 @@ -549,9 +549,9 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
430         enquire.set_docid_order(Xapian::Enquire::ASCENDING);\r
431  \r
432         if (_debug_query ()) {\r
433 -           fprintf (stderr, "Exclude query is:\n%s\n",\r
434 +           notmuch_database_log (notmuch, "Exclude query is:\n%s\n",\r
435                      exclude_query.get_description ().c_str ());\r
436 -           fprintf (stderr, "Final query is:\n%s\n",\r
437 +           notmuch_database_log (notmuch, "Final query is:\n%s\n",\r
438                      final_query.get_description ().c_str ());\r
439         }\r
440  \r
441 @@ -562,9 +562,9 @@ notmuch_query_count_messages (notmuch_query_t *query)\r
442         count = mset.get_matches_estimated();\r
443  \r
444      } catch (const Xapian::Error &error) {\r
445 -       fprintf (stderr, "A Xapian exception occurred: %s\n",\r
446 +       notmuch_database_log (notmuch, "A Xapian exception occurred: %s\n",\r
447                  error.get_msg().c_str());\r
448 -       fprintf (stderr, "Query string was: %s\n", query->query_string);\r
449 +       notmuch_database_log (notmuch, "Query string was: %s\n", query->query_string);\r
450      }\r
451  \r
452      return count;\r
453 -- \r
454 2.1.3\r
455 \r