1 Return-Path: <amthrax@drake.mit.edu>
\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 E4700431FD7
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Mar 2012 19:31:36 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 2th75KH-+UWj for <notmuch@notmuchmail.org>;
\r
16 Tue, 13 Mar 2012 19:31:34 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id B85A2431FAE
\r
20 for <notmuch@notmuchmail.org>; Tue, 13 Mar 2012 19:31:34 -0700 (PDT)
\r
21 X-AuditID: 1209190e-b7f7c6d0000008c3-92-4f600306a025
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 0E.82.02243.603006F4; Tue, 13 Mar 2012 22:31:34 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q2E2VYen007532;
\r
27 Tue, 13 Mar 2012 22:31:34 -0400
\r
28 Received: from drake.mit.edu
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q2E2VWG3023783
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Tue, 13 Mar 2012 22:31:33 -0400 (EDT)
\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)
\r
36 (envelope-from <amthrax@drake.mit.edu>)
\r
37 id 1S7dzw-0007DC-IS; Tue, 13 Mar 2012 22:31:32 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 1/2] lib: Expose query debug output via an environment
\r
42 Date: Tue, 13 Mar 2012 22:31:30 -0400
\r
43 Message-Id: <1331692291-27671-2-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.7.3
\r
45 In-Reply-To: <1331692291-27671-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1331692291-27671-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrMvGnOBv0NcqaXH95kxmB0aPZ6tu
\r
49 MQcwRnHZpKTmZJalFunbJXBlNK2fw1QwQaDi84q0BsZO3i5GTg4JAROJ1+/XsULYYhIX7q1n
\r
50 62Lk4hAS2McocbT/LDtIQkhgA6PE+on5EIn7TBLHfl9hh3DmM0ocuLeeGaSKTUBDYtv+5Ywg
\r
51 toiAtMTOu7OBxnJwMAuoSfzpUgEJCwv4S8w+PhlsKIuAqsTfyUuZQGxeAQeJhU2tjBBXKEic
\r
52 W30OrIZTwFHi0v95jBBHOEg0LH/PNoGRfwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdY73c
\r
53 zBK91JTSTYzgkJHk28H49aDSIUYBDkYlHl7h2nh/IdbEsuLK3EOMkhxMSqK8kW+BQnxJ+SmV
\r
54 GYnFGfFFpTmpxYcYJTiYlUR4X0wFyvGmJFZWpRblw6SkOViUxHnVtN75CQmkJ5akZqemFqQW
\r
55 wWRlODiUJHhVQIYKFqWmp1akZeaUIKSZODhBhvMADS//DjK8uCAxtzgzHSJ/ilFRSpz3zhug
\r
56 hABIIqM0D64XFtOvGMWBXhHmXQlSxQNMB3Ddr4AGMwENLvkWBzK4JBEhJdXAyLjgm9k7n09V
\r
57 n5V7rmqGu8yU+/HDe+uE7wpNP3pMv/vp3VjDwnmp+gj3xfCGzBDtlpff8lnbJs38tfRYzMKc
\r
58 0+1hWblhYt9MpjSc2BVyXtNEcu3UpkONHyd0Vd3dO53JQOj9nuI7l5j3GG+vn3N1j/NcyS/f
\r
59 Z0u33CiI8Xte1VFR8Obn1fa7f5VYijMSDbWYi4oTAbBDShTEAgAA
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\r
63 List-Id: "Use and development of the notmuch mail system."
\r
64 <notmuch.notmuchmail.org>
\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
68 List-Post: <mailto:notmuch@notmuchmail.org>
\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
71 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
72 X-List-Received-Date: Wed, 14 Mar 2012 02:31:37 -0000
\r
74 Allow query debugging to be enabled at run-time by setting the
\r
75 NOTMUCH_DEBUG_QUERY environment variable to a non-empty string.
\r
77 Previously, enabling query debugging required recompiling, but parsed
\r
78 queries are often useful for tracking down bugs in situations where
\r
79 recompiling is inconvenient.
\r
81 lib/query.cc | 24 +++++++++++++++---------
\r
82 1 files changed, 15 insertions(+), 9 deletions(-)
\r
84 diff --git a/lib/query.cc b/lib/query.cc
\r
85 index ab18fbc..1e5e99a 100644
\r
88 @@ -64,15 +64,21 @@ _notmuch_doc_id_set_init (void *ctx,
\r
89 notmuch_doc_id_set_t *doc_ids,
\r
92 +static notmuch_bool_t
\r
93 +_debug_query (void)
\r
95 + char *env = getenv ("NOTMUCH_DEBUG_QUERY");
\r
96 + return (env && strcmp (env, "") != 0);
\r
100 notmuch_query_create (notmuch_database_t *notmuch,
\r
101 const char *query_string)
\r
103 notmuch_query_t *query;
\r
105 -#ifdef DEBUG_QUERY
\r
106 - fprintf (stderr, "Query string is:\n%s\n", query_string);
\r
108 + if (_debug_query ())
\r
109 + fprintf (stderr, "Query string is:\n%s\n", query_string);
\r
111 query = talloc (NULL, notmuch_query_t);
\r
112 if (unlikely (query == NULL))
\r
113 @@ -255,9 +261,9 @@ notmuch_query_search_messages (notmuch_query_t *query)
\r
118 - fprintf (stderr, "Final query is:\n%s\n", final_query.get_description().c_str());
\r
120 + if (_debug_query ())
\r
121 + fprintf (stderr, "Final query is:\n%s\n",
\r
122 + final_query.get_description ().c_str ());
\r
124 enquire.set_query (final_query);
\r
126 @@ -531,9 +537,9 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
127 enquire.set_weighting_scheme(Xapian::BoolWeight());
\r
128 enquire.set_docid_order(Xapian::Enquire::ASCENDING);
\r
131 - fprintf (stderr, "Final query is:\n%s\n", final_query.get_description().c_str());
\r
133 + if (_debug_query ())
\r
134 + fprintf (stderr, "Final query is:\n%s\n",
\r
135 + final_query.get_description ().c_str ());
\r
137 enquire.set_query (final_query);
\r