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 9060C40D143 for ; Mon, 11 Oct 2010 06:27:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.6 X-Spam-Level: X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham 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 bVgLzn2PX9DU for ; Mon, 11 Oct 2010 06:27:29 -0700 (PDT) Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) by olra.theworths.org (Postfix) with ESMTP id 37F5C40BFDB for ; Mon, 11 Oct 2010 06:27:19 -0700 (PDT) Received: from rocinante.cs.unb.ca (fctnnbsc30w-142167176217.pppoe-dynamic.High-Speed.nb.bellaliant.net [142.167.176.217]) (authenticated bits=0) by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id o9BDRIGS003867 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 11 Oct 2010 10:27:18 -0300 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.72) (envelope-from ) id 1P5IPO-0004cd-J5; Mon, 11 Oct 2010 10:27:18 -0300 From: david@tethera.net To: notmuch@notmuchmail.org Subject: [PATCH 2/3] notmuch-log.c: Add a function to log a pair of strings with a timestamp. Date: Mon, 11 Oct 2010 10:26:56 -0300 Message-Id: <1286803617-17328-3-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1286803617-17328-1-git-send-email-david@tethera.net> References: <1286803617-17328-1-git-send-email-david@tethera.net> Cc: David Bremner 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: Mon, 11 Oct 2010 13:27:42 -0000 From: David Bremner Since the function is supposed to work for any pair of strings, this means some form of quoting seems necessary. I decided to re-use the json quoting routines for convenience. --- notmuch-client.h | 4 ++++ notmuch-log.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 0422b1c..a849e21 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -201,6 +201,10 @@ notmuch_log_open (const char *path); notmuch_status_t notmuch_log_append (int file_desc, const char *buffer, size_t len); +notmuch_status_t +notmuch_log_string_pair (void *ctx, int file_desc, + const char *str1, const char *str2); + notmuch_bool_t debugger_is_active (void); diff --git a/notmuch-log.c b/notmuch-log.c index c4ddcd3..b0aca95 100644 --- a/notmuch-log.c +++ b/notmuch-log.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "notmuch-client.h" /* @@ -100,3 +102,19 @@ notmuch_log_append (int file_desc, const char *buffer, size_t len){ return NOTMUCH_STATUS_SUCCESS; } + +notmuch_status_t +notmuch_log_string_pair(void *ctx, int log_fd, + const char *string1, const char *string2){ + + char *quoted1, *quoted2, *buffer; + + quoted1 = json_quote_str (ctx, string1); + quoted2 = json_quote_str (ctx, string2); + + buffer = talloc_asprintf (ctx, "%ld %s %s\n", + (long)time(NULL), + quoted1, quoted2); + + return notmuch_log_append (log_fd, buffer, strlen(buffer)); +} -- 1.7.1