From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 679D73777 for ; Thu, 5 Jan 2017 15:53:16 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 05 Jan 2017 06:53:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,321,1477983600"; d="scan'208";a="26558273" Received: from gklab-246-019.igk.intel.com (HELO intel.com) ([10.217.246.19]) by orsmga002.jf.intel.com with SMTP; 05 Jan 2017 06:53:12 -0800 Received: by intel.com (sSMTP sendmail emulation); Thu, 05 Jan 2017 17:52:26 +0100 From: Slawomir Mrozowicz To: dev@dpdk.org Cc: Slawomir Mrozowicz , Declan Doherty Date: Thu, 5 Jan 2017 17:49:59 +0100 Message-Id: <1483635001-15473-2-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483635001-15473-1-git-send-email-slawomirx.mrozowicz@intel.com> References: <1480691702-4600-1-git-send-email-michalx.k.jastrzebski@intel.com> <1483635001-15473-1-git-send-email-slawomirx.mrozowicz@intel.com> Subject: [dpdk-dev] [PATCH v2 1/3] eal: add quiet mode to suppress log output to stdout X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 14:53:16 -0000 Add EAL option to suppresses all log output to stdout. Signed-off-by: Declan Doherty --- lib/librte_eal/common/eal_common_log.c | 13 +++++++++++++ lib/librte_eal/common/eal_common_options.c | 10 +++++++++- lib/librte_eal/common/eal_options.h | 2 ++ lib/librte_eal/common/include/rte_log.h | 15 +++++++++++++++ lib/librte_eal/linuxapp/eal/eal_log.c | 8 +++++--- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 8 ++++++++ 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index e45d326..701b309 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -45,6 +45,7 @@ struct rte_logs rte_logs = { .type = ~0, .level = RTE_LOG_DEBUG, + .silent = 0, .file = NULL, }; @@ -87,6 +88,18 @@ rte_get_log_level(void) return rte_logs.level; } +void +rte_log_silence_stdout(void) +{ + rte_logs.silent = 1; +} + +int +rte_log_stdout_silent(void) +{ + return rte_logs.silent; +} + /* Set global log type */ void rte_set_log_type(uint32_t type, int enable) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 611e581..c47e02b 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -69,6 +69,7 @@ eal_short_options[] = "r:" /* memory ranks */ "v" /* version */ "w:" /* pci-whitelist */ + "s" /* silence log output to stdout */ ; const struct option @@ -95,6 +96,7 @@ eal_long_options[] = { {OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM }, {OPT_VMWARE_TSC_MAP, 0, NULL, OPT_VMWARE_TSC_MAP_NUM }, {OPT_XEN_DOM0, 0, NULL, OPT_XEN_DOM0_NUM }, + {OPT_LOG_STDOUT_SILENT, 0, NULL, OPT_LOG_STDOUT_SILENT_NUM }, {0, 0, NULL, 0 } }; @@ -844,6 +846,9 @@ eal_parse_common_option(int opt, const char *optarg, * even if info or warning messages are disabled */ RTE_LOG(CRIT, EAL, "RTE Version: '%s'\n", rte_version()); break; + case 's': + rte_log_silence_stdout(); + break; /* long options */ case OPT_HUGE_UNLINK_NUM: @@ -1055,9 +1060,12 @@ eal_common_usage(void) " -d LIB.so|DIR Add a driver or driver directory\n" " (can be used multiple times)\n" " --"OPT_VMWARE_TSC_MAP" Use VMware TSC map instead of native RDTSC\n" - " --"OPT_PROC_TYPE" Type of this process (primary|secondary|auto)\n" + " --"OPT_PROC_TYPE" Type of this process " + "(primary|secondary|auto)\n" " --"OPT_SYSLOG" Set syslog facility\n" " --"OPT_LOG_LEVEL" Set default log level\n" + " -s, --"OPT_LOG_STDOUT_SILENT" Silent mode, suppresses log " + "output to stdout\n" " -v Display version information on startup\n" " -h, --help This help\n" "\nEAL options for DEBUG use only:\n" diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index a881c62..bd9778f 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -41,6 +41,8 @@ enum { OPT_PCI_BLACKLIST_NUM = 'b', #define OPT_PCI_WHITELIST "pci-whitelist" OPT_PCI_WHITELIST_NUM = 'w', +#define OPT_LOG_STDOUT_SILENT "log-stdout-silent" + OPT_LOG_STDOUT_SILENT_NUM = 's', /* first long only option value must be >= 256, so that we won't * conflict with short options */ diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h index 671e274..3898676 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -54,6 +54,7 @@ extern "C" { struct rte_logs { uint32_t type; /**< Bitfield with enabled logs. */ uint32_t level; /**< Log level. */ + uint32_t silent; /**< silence logging to stdout */ FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */ }; @@ -132,6 +133,20 @@ void rte_set_log_level(uint32_t level); uint32_t rte_get_log_level(void); /** + * Silence output to stdout by logging facilities + */ +void rte_log_silence_stdout(void); + +/** + * Check if echoing log output to stdout is enabled. + * + * @return + * - Returns 0 if echoing to logging to stdout is enabled + * - Returns 1 if logging is in silent mode + */ +int rte_log_stdout_silent(void); + +/** * Enable or disable the log type. * * @param type diff --git a/lib/librte_eal/linuxapp/eal/eal_log.c b/lib/librte_eal/linuxapp/eal/eal_log.c index e3a50aa..d88ed82 100644 --- a/lib/librte_eal/linuxapp/eal/eal_log.c +++ b/lib/librte_eal/linuxapp/eal/eal_log.c @@ -56,12 +56,14 @@ static ssize_t console_log_write(__attribute__((unused)) void *c, const char *buf, size_t size) { char copybuf[BUFSIZ + 1]; - ssize_t ret; + ssize_t ret = 0; uint32_t loglevel; /* write on stdout */ - ret = fwrite(buf, 1, size, stdout); - fflush(stdout); + if (!rte_log_stdout_silent()) { + ret = fwrite(buf, 1, size, stdout); + fflush(stdout); + } /* truncate message if too big (should not happen) */ if (size > BUFSIZ) diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 83721ba..f60c3f7 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -178,3 +178,11 @@ DPDK_16.11 { rte_eal_vdrv_unregister; } DPDK_16.07; + +DPDK_17.02 { + global: + + rte_log_stdout_silent; + rte_log_silence_stdout; + +} DPDK_16.11; -- 2.5.0