1 Return-Path: <bremner@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 0657540D14C
\r
6 for <notmuch@notmuchmail.org>; Mon, 11 Oct 2010 06:27:50 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
\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 pFpojjWdI5Y9 for <notmuch@notmuchmail.org>;
\r
16 Mon, 11 Oct 2010 06:27:36 -0700 (PDT)
\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 753FA40BFDE
\r
19 for <notmuch@notmuchmail.org>; Mon, 11 Oct 2010 06:27:19 -0700 (PDT)
\r
20 Received: from rocinante.cs.unb.ca
\r
21 (fctnnbsc30w-142167176217.pppoe-dynamic.High-Speed.nb.bellaliant.net
\r
22 [142.167.176.217]) (authenticated bits=0)
\r
23 by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id o9BDRIBb003871
\r
24 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
\r
25 Mon, 11 Oct 2010 10:27:18 -0300
\r
26 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.72)
\r
27 (envelope-from <bremner@unb.ca>)
\r
28 id 1P5IPO-0004cf-Kz; Mon, 11 Oct 2010 10:27:18 -0300
\r
29 From: david@tethera.net
\r
30 To: notmuch@notmuchmail.org
\r
31 Subject: [PATCH 3/3] notmuch-tag.c: Add tag logging.
\r
32 Date: Mon, 11 Oct 2010 10:26:57 -0300
\r
33 Message-Id: <1286803617-17328-4-git-send-email-david@tethera.net>
\r
34 X-Mailer: git-send-email 1.7.1
\r
35 In-Reply-To: <1286803617-17328-1-git-send-email-david@tethera.net>
\r
36 References: <1286803617-17328-1-git-send-email-david@tethera.net>
\r
37 Cc: David Bremner <bremner@unb.ca>
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Mon, 11 Oct 2010 13:27:50 -0000
\r
52 From: David Bremner <bremner@unb.ca>
\r
54 logging of tags is enabled by adding a stanza like
\r
57 tags = /some/path/you/can/write/to
\r
59 to your notmuch config.
\r
61 Note that we intentionally do the logging after the database
\r
62 transaction is finished.
\r
64 notmuch-tag.c | 31 +++++++++++++++++++++++++++++++
\r
65 1 files changed, 31 insertions(+), 0 deletions(-)
\r
67 diff --git a/notmuch-tag.c b/notmuch-tag.c
\r
68 index fd54bc7..f24d1e4 100644
\r
71 @@ -46,6 +46,9 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
72 notmuch_message_t *message;
\r
73 struct sigaction action;
\r
76 + notmuch_bool_t enable_log = FALSE;
\r
77 + const char *log_path;
\r
79 /* Setup our handler for SIGINT */
\r
80 memset (&action, 0, sizeof (struct sigaction));
\r
81 @@ -96,6 +99,17 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
85 + log_path = notmuch_config_get_log_path (config, "tags");
\r
87 + if (log_path != NULL) {
\r
88 + enable_log = TRUE;
\r
90 + log_fd = notmuch_log_open(log_path);
\r
96 notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
\r
97 NOTMUCH_DATABASE_MODE_READ_WRITE);
\r
98 if (notmuch == NULL)
\r
99 @@ -114,10 +128,15 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
100 notmuch_messages_valid (messages) && !interrupted;
\r
101 notmuch_messages_move_to_next (messages))
\r
103 + const char *message_id = NULL;
\r
104 message = notmuch_messages_get (messages);
\r
106 notmuch_message_freeze (message);
\r
109 + message_id = talloc_strdup (ctx,
\r
110 + notmuch_message_get_message_id (message));
\r
112 for (i = 0; i < remove_tags_count; i++)
\r
113 notmuch_message_remove_tag (message,
\r
114 argv[remove_tags[i]] + 1);
\r
115 @@ -128,6 +147,18 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
116 notmuch_message_thaw (message);
\r
118 notmuch_message_destroy (message);
\r
120 + if (enable_log) {
\r
121 + for (i = 0; i < remove_tags_count; i++)
\r
122 + notmuch_log_string_pair (ctx, log_fd,
\r
124 + argv[remove_tags[i]]);
\r
126 + for (i = 0; i < add_tags_count; i++)
\r
127 + notmuch_log_string_pair (ctx, log_fd,
\r
129 + argv[add_tags[i]]);
\r
133 notmuch_query_destroy (query);
\r