From patchwork Tue Nov 26 11:41:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 3238861 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E93759F3A0 for ; Tue, 26 Nov 2013 11:46:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B467E2013A for ; Tue, 26 Nov 2013 11:46:42 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id ED54B2011E for ; Tue, 26 Nov 2013 11:46:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAQBgoRh002393; Tue, 26 Nov 2013 06:43:26 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAQBfhKF010319 for ; Tue, 26 Nov 2013 06:41:43 -0500 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rAQBfhhl005699; Tue, 26 Nov 2013 06:41:43 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAQBfgwX009453; Tue, 26 Nov 2013 06:41:42 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DAF57A7B6A; Tue, 26 Nov 2013 12:41:41 +0100 (CET) From: Hannes Reinecke To: Christophe Varoqui Date: Tue, 26 Nov 2013 12:41:24 +0100 Message-Id: <1385466090-24290-4-git-send-email-hare@suse.de> In-Reply-To: <1385466090-24290-1-git-send-email-hare@suse.de> References: <1385466090-24290-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -6.9 (BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 3/9] multipathd: Add option '-s' to suppress timestamps X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP systemd prefixes any messages to stdout with a timestamp, so it's quite pointless to do it ourself. Signed-off-by: Hannes Reinecke --- libmultipath/debug.c | 17 ++++++++++------- libmultipath/devmapper.c | 16 +++++++++------- multipathd/main.c | 11 +++++++---- multipathd/multipathd.8 | 7 +++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/libmultipath/debug.c b/libmultipath/debug.c index d30517d..bad78a8 100644 --- a/libmultipath/debug.c +++ b/libmultipath/debug.c @@ -21,15 +21,18 @@ void dlog (int sink, int prio, const char * fmt, ...) thres = (conf) ? conf->verbosity : 0; if (prio <= thres) { - if (!sink) { - time_t t = time(NULL); - struct tm *tb = localtime(&t); - char buff[16]; + if (sink < 1) { + if (sink == 0) { + time_t t = time(NULL); + struct tm *tb = localtime(&t); + char buff[16]; - strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb); - buff[sizeof(buff)-1] = '\0'; + strftime(buff, sizeof(buff), + "%b %d %H:%M:%S", tb); + buff[sizeof(buff)-1] = '\0'; - fprintf(stdout, "%s | ", buff); + fprintf(stdout, "%s | ", buff); + } vfprintf(stdout, fmt, ap); } else diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 4c8b923..71281e6 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -71,15 +71,17 @@ dm_write_log (int level, const char *file, int line, const char *f, ...) return; va_start(ap, f); - if (!logsink) { - time_t t = time(NULL); - struct tm *tb = localtime(&t); - char buff[16]; + if (logsink < 1) { + if (logsink == 0) { + time_t t = time(NULL); + struct tm *tb = localtime(&t); + char buff[16]; - strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb); - buff[sizeof(buff)-1] = '\0'; + strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb); + buff[sizeof(buff)-1] = '\0'; - fprintf(stdout, "%s | ", buff); + fprintf(stdout, "%s | ", buff); + } fprintf(stdout, "libdevmapper: %s(%i): ", file, line); vfprintf(stdout, f, ap); fprintf(stdout, "\n"); diff --git a/multipathd/main.c b/multipathd/main.c index 91d7bfc..78d9265 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1597,7 +1597,7 @@ child (void * param) setup_thread_attr(&uevent_attr, 128 * 1024, 1); setup_thread_attr(&waiter_attr, 32 * 1024, 1); - if (logsink) { + if (logsink == 1) { setup_thread_attr(&log_attr, 64 * 1024, 0); log_thread_start(&log_attr); pthread_attr_destroy(&log_attr); @@ -1749,7 +1749,7 @@ child (void * param) condlog(2, "--------shut down-------"); - if (logsink) + if (logsink == 1) log_thread_stop(); /* @@ -1849,7 +1849,7 @@ main (int argc, char *argv[]) if (!conf) exit(1); - while ((arg = getopt(argc, argv, ":dv:k::")) != EOF ) { + while ((arg = getopt(argc, argv, ":dsv:k::")) != EOF ) { switch(arg) { case 'd': logsink = 0; @@ -1862,6 +1862,9 @@ main (int argc, char *argv[]) conf->verbosity = atoi(optarg); break; + case 's': + logsink = -1; + break; case 'k': uxclnt(optarg); exit(0); @@ -1886,7 +1889,7 @@ main (int argc, char *argv[]) exit(0); } - if (!logsink) + if (logsink < 1) err = 0; else err = daemonize(); diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 index ccc5f54..2aea150 100644 --- a/multipathd/multipathd.8 +++ b/multipathd/multipathd.8 @@ -20,8 +20,11 @@ devmap reconfiguration, so that it can refresh its failed path list. .SH OPTIONS .TP .B \-d -Forground Mode. Don't daemonize, and print all messages to stdout and stderr. -.TP +Foreground Mode. Don't daemonize, and print all messages to stdout and stderr. +.TP +.B \-s +Suppress timestamps. Do not prefix logging messages with a timestamp. +.TP .B -v "level" Verbosity level. Print additional information while running multipathd. A level of 0 means only print errors. A level of 3 or greater prints debugging information as well. .TP