From 283d0191cb4998cda4694515160eb2158b5a99d0 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 28 Dec 2014 18:33:44 +0100 Subject: [PATCH] libnotmuch logging overhaul v3 --- c0/c21df4579ecb9cb4f524e23287c5653bcb5bb2 | 141 ++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 c0/c21df4579ecb9cb4f524e23287c5653bcb5bb2 diff --git a/c0/c21df4579ecb9cb4f524e23287c5653bcb5bb2 b/c0/c21df4579ecb9cb4f524e23287c5653bcb5bb2 new file mode 100644 index 000000000..3f9b884d7 --- /dev/null +++ b/c0/c21df4579ecb9cb4f524e23287c5653bcb5bb2 @@ -0,0 +1,141 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id B3F12431FC4 + for ; Sun, 28 Dec 2014 09:37:53 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id oFq2xBFWr5nl for ; + Sun, 28 Dec 2014 09:37:50 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 73754431FB6 + for ; Sun, 28 Dec 2014 09:37:50 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) id 1Y5Hmk-0002fM-EV + for notmuch@notmuchmail.org; Sun, 28 Dec 2014 13:37:46 -0400 +Received: (nullmailer pid 11491 invoked by uid 1000); Sun, 28 Dec 2014 + 17:37:40 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: libnotmuch logging overhaul v3 +Date: Sun, 28 Dec 2014 18:33:44 +0100 +Message-Id: <1419788030-10567-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.3 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 28 Dec 2014 17:37:53 -0000 + +changes since the last round [1] + +- remove unused variable +- fix the internal usage of n_d_open to use _verbose version +- revert the hiding of query debugging. + +[1]: id:1419717937-1108-2-git-send-email-david@tethera.net + +diff --git a/lib/database.cc b/lib/database.cc +index 16cd940..b144885 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -377,7 +377,6 @@ _notmuch_database_log (notmuch_database_t *notmuch, + ...) + { + va_list va_args; +- const char *message; + + va_start (va_args, format); + +@@ -693,9 +692,9 @@ notmuch_database_create_verbose (const char *path, + goto DONE; + } + +- status = notmuch_database_open (path, +- NOTMUCH_DATABASE_MODE_READ_WRITE, +- ¬much); ++ status = notmuch_database_open_verbose (path, ++ NOTMUCH_DATABASE_MODE_READ_WRITE, ++ ¬much, &message); + if (status) + goto DONE; + +@@ -1101,13 +1100,18 @@ notmuch_database_compact (const char *path, + notmuch_database_t *notmuch = NULL; + struct stat statbuf; + notmuch_bool_t keep_backup; ++ char *message = NULL; + + local = talloc_new (NULL); + if (! local) + return NOTMUCH_STATUS_OUT_OF_MEMORY; + +- ret = notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much); ++ ret = notmuch_database_open_verbose (path, ++ NOTMUCH_DATABASE_MODE_READ_WRITE, ++ ¬much, ++ &message); + if (ret) { ++ if (status_cb) status_cb (message, closure); + goto DONE; + } + +diff --git a/lib/query.cc b/lib/query.cc +index 2e20ab2..9ed420c 100644 +--- a/lib/query.cc ++++ b/lib/query.cc +@@ -78,7 +78,7 @@ notmuch_query_create (notmuch_database_t *notmuch, + notmuch_query_t *query; + + if (_debug_query ()) +- _notmuch_database_log (notmuch, "Query string is:\n%s\n", query_string); ++ fprintf (stderr, "Query string is:\n%s\n", query_string); + + query = talloc (notmuch, notmuch_query_t); + if (unlikely (query == NULL)) +@@ -266,9 +266,9 @@ notmuch_query_search_messages (notmuch_query_t *query) + } + + if (_debug_query ()) { +- _notmuch_database_log (notmuch, "Exclude query is:\n%s\n", ++ fprintf (stderr, "Exclude query is:\n%s\n", + exclude_query.get_description ().c_str ()); +- _notmuch_database_log (notmuch, "Final query is:\n%s\n", ++ fprintf (stderr, "Final query is:\n%s\n", + final_query.get_description ().c_str ()); + } + +@@ -549,9 +549,9 @@ notmuch_query_count_messages (notmuch_query_t *query) + enquire.set_docid_order(Xapian::Enquire::ASCENDING); + + if (_debug_query ()) { +- _notmuch_database_log (notmuch, "Exclude query is:\n%s\n", ++ fprintf (stderr, "Exclude query is:\n%s\n", + exclude_query.get_description ().c_str ()); +- _notmuch_database_log (notmuch, "Final query is:\n%s\n", ++ fprintf (stderr, "Final query is:\n%s\n", + final_query.get_description ().c_str ()); + } + + + lib/database.cc | 14 +++++++++----- + lib/query.cc | 10 +++++----- + 2 files changed, 14 insertions(+), 10 deletions(-) + -- 2.26.2