From 4872f037816f9d7050818b9d907d3b1d97280510 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 26 Dec 2014 18:42:38 +0100 Subject: [PATCH] [PATCH 1/4] lib: add passthrough logger function --- 7e/e3207569f4985eaf58cc3f6432e1dbb892bd49 | 111 ++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 7e/e3207569f4985eaf58cc3f6432e1dbb892bd49 diff --git a/7e/e3207569f4985eaf58cc3f6432e1dbb892bd49 b/7e/e3207569f4985eaf58cc3f6432e1dbb892bd49 new file mode 100644 index 000000000..ac85e0f2f --- /dev/null +++ b/7e/e3207569f4985eaf58cc3f6432e1dbb892bd49 @@ -0,0 +1,111 @@ +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 19B96429E2F + for ; Fri, 26 Dec 2014 09:43:32 -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 lzVi4lkXW0Vx for ; + Fri, 26 Dec 2014 09:43:31 -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 18FB0429E2E + for ; Fri, 26 Dec 2014 09:43:31 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1Y4YvC-00060J-My; Fri, 26 Dec 2014 13:43:30 -0400 +Received: (nullmailer pid 21754 invoked by uid 1000); Fri, 26 Dec 2014 + 17:43:08 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 1/4] lib: add passthrough logger function +Date: Fri, 26 Dec 2014 18:42:38 +0100 +Message-Id: <1419615761-21581-2-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.3 +In-Reply-To: <1419615761-21581-1-git-send-email-david@tethera.net> +References: <1419615761-21581-1-git-send-email-david@tethera.net> +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: Fri, 26 Dec 2014 17:43:32 -0000 + +As a first step to eliminating all the fprintfs in the library, make a +logger function that just calls fprintf. This is a bit more complex +than needed, because we want to do something more interesting with the +formatted string in the future. +--- + lib/database.cc | 19 +++++++++++++++++++ + lib/notmuch.h | 10 +++++++++- + 2 files changed, 28 insertions(+), 1 deletion(-) + +diff --git a/lib/database.cc b/lib/database.cc +index 3601f9d..f3c62ee 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -916,6 +916,25 @@ notmuch_database_open (const char *path, + return status; + } + ++void ++notmuch_database_log (notmuch_database_t *notmuch, ++ const char *format, ++ ...) ++{ ++ va_list va_args; ++ const char *message; ++ ++ va_start (va_args, format); ++ ++ message = talloc_vasprintf (notmuch, format, va_args); ++ ++ /* XXX do something more clever here */ ++ fputs (message, stderr); ++ ++ talloc_free ((char *)message); ++ ++} ++ + notmuch_status_t + notmuch_database_close (notmuch_database_t *notmuch) + { +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 220839b..c8c8124 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -279,7 +279,15 @@ notmuch_status_t + notmuch_database_open (const char *path, + notmuch_database_mode_t mode, + notmuch_database_t **database); +- ++/** ++ * Log a message to where the database is configured to log it ++ * ++ * Initially this does notmuch interesting, since the output is not ++ * yet configurable. ++ */ ++void ++notmuch_database_log (notmuch_database_t *notmuch, ++ const char *format, ...); + /** + * Commit changes and close the given notmuch database. + * +-- +2.1.3 + -- 2.26.2