From patchwork Fri Nov 15 10:29:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 3187631 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED076C045B for ; Fri, 15 Nov 2013 10:34:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4F4D207D2 for ; Fri, 15 Nov 2013 10:34:07 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 095EC207CF for ; Fri, 15 Nov 2013 10:34:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAFAVH8F027967; Fri, 15 Nov 2013 05:31:17 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAFAUJ63018595 for ; Fri, 15 Nov 2013 05:30:19 -0500 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rAFAUJn5013689 for ; Fri, 15 Nov 2013 05:30:19 -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 rAFAUF3l020973 for ; Fri, 15 Nov 2013 05:30:18 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 96CC8A70DC; Fri, 15 Nov 2013 11:30:15 +0100 (CET) From: Hannes Reinecke To: Christophe Varoqui Date: Fri, 15 Nov 2013 11:29:39 +0100 Message-Id: <1384511384-27642-9-git-send-email-hare@suse.de> In-Reply-To: <1384511384-27642-1-git-send-email-hare@suse.de> References: <1384511384-27642-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.3 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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 08/13] 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 +++++-- multipathd/multipathd.service | 2 +- 5 files changed, 32 insertions(+), 21 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 b4146fd..72b3740 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1598,7 +1598,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); @@ -1754,7 +1754,7 @@ child (void * param) condlog(2, "--------shut down-------"); - if (logsink) + if (logsink == 1) log_thread_stop(); /* @@ -1854,7 +1854,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; @@ -1867,6 +1867,9 @@ main (int argc, char *argv[]) conf->verbosity = atoi(optarg); break; + case 's': + logsink = -1; + break; case 'k': uxclnt(optarg); exit(0); @@ -1891,7 +1894,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 diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service index 03b4270..fb84025 100644 --- a/multipathd/multipathd.service +++ b/multipathd/multipathd.service @@ -8,7 +8,7 @@ Conflicts=shutdown.target [Service] Type=notify NotifyAccess=main -ExecStart=/sbin/multipathd -d +ExecStart=/sbin/multipathd -d -s ExecReload=/sbin/multipathd reconfigure [Install]