From patchwork Sat Feb 28 00:54:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 23861 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 8D6C3DDFB1 for ; Sat, 28 Feb 2009 12:13:47 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8489EDDDB6; Sat, 28 Feb 2009 12:00:03 +1100 (EST) Received: from hera.kernel.org (IDENT:U2FsdGVkX18Up6eXPckbOm92pFpzEFMtMVsfzzB2U/U@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n1S0xrst016923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 28 Feb 2009 00:59:53 GMT Received: (from geoff@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n1S0xq9q016922; Sat, 28 Feb 2009 00:59:52 GMT Message-Id: <20090228005351.105452208@am.sony.com> References: <20090228005350.203477145@am.sony.com> In-reply-to: <20090228005350.203477145@am.sony.com> User-Agent: quilt/0.46-1 Date: Fri, 27 Feb 2009 16:54:06 -0800 From: Geoff Levand To: Jeremy Kerr Content-Disposition: inline; filename=discover-log-to-file.diff X-Virus-Scanned: ClamAV 0.93.3/9055/Fri Feb 27 20:16:01 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Sat, 28 Feb 2009 00:59:54 +0000 (UTC) Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 16/16] petitboot: Log server messages to file X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Log discover server messages to a file. Helps in debugging the server when is has problems at system startup. Signed-off-by: Geoff Levand --- discover/discover-server.c | 4 ++-- discover/params.c | 8 ++++---- discover/pb-discover.c | 12 ++++++++++++ discover/udev.c | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) --- a/discover/discover-server.c +++ b/discover/discover-server.c @@ -66,12 +66,12 @@ static void print_clients(struct discove { struct client *client; - printf("current clients [%p,%p,%p]:\n", + pb_log("current clients [%p,%p,%p]:\n", &server->clients.head, server->clients.head.prev, server->clients.head.next); list_for_each_entry(&server->clients, client, list) - printf("\t[%p,%p,%p] client: %d\n", &client->list, + pb_log("\t[%p,%p,%p] client: %d\n", &client->list, client->list.prev, client->list.next, client->fd); } --- a/discover/params.c +++ b/discover/params.c @@ -28,10 +28,10 @@ #define realloc_array(ptr, type, num) \ ((type *)_realloc_array((ptr), sizeof(type), (num))) -#define rprintf(x, ...) do { fprintf(stderr, ##__VA_ARGS__); \ - fprintf(stderr, "\n"); } while (0) -#define rsyserr(x, y, ...) do { fprintf(stderr, ##__VA_ARGS__); \ - fprintf(stderr, "\n"); } while (0) +#define rprintf(x, ...) do { pb_log(stderr, ##__VA_ARGS__); \ + pb_log(stderr, "\n"); } while (0) +#define rsyserr(x, y, ...) do { pb_log(stderr, ##__VA_ARGS__); \ + pb_log(stderr, "\n"); } while (0) #define MALLOC_MAX 0x40000000 #define False 0 --- a/discover/pb-discover.c +++ b/discover/pb-discover.c @@ -1,4 +1,5 @@ +#include #include #include @@ -21,6 +22,16 @@ int main(void) struct device_handler *handler; struct discover_server *server; struct udev *udev; + FILE *log; + + log = fopen("pb-discover.log", "a"); + assert(log); + pb_log_set_stream(log); + +#if defined(DEBUG) + pb_log_always_flush(1); +#endif + pb_log("--- pb-discover ---\n"); /* we look for closed sockets when we write, so ignore SIGPIPE */ signal(SIGPIPE, SIG_IGN); @@ -48,6 +59,7 @@ int main(void) device_handler_destroy(handler); + pb_log("--- end ---\n"); return EXIT_SUCCESS; } --- a/discover/udev.c +++ b/discover/udev.c @@ -82,10 +82,10 @@ static void print_event(struct udev_even action = event->action == UDEV_ACTION_ADD ? "add" : "remove"; pb_log("udev %s event:\n", action); - printf("\tdevice: %s\n", event->device); + pb_log("\tdevice: %s\n", event->device); for (i = 0; params[i]; i++) - printf("\t%-12s => %s\n", + pb_log("\t%-12s => %s\n", params[i], udev_event_param(event, params[i])); }