From: Stephen Hemminger Date: Wed, 25 Apr 2018 15:56:42 +0000 (-0700) Subject: net/failsafe: convert to dynamic logging X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ebeb72ecc49b00dd6d9cf31b1d4b6645203811be;p=dpdk.git net/failsafe: convert to dynamic logging Signed-off-by: Stephen Hemminger Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index dc9b0d0888..5e7a8ba1b0 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -13,6 +13,8 @@ #include "failsafe_private.h" +int failsafe_logtype; + const char pmd_failsafe_driver_name[] = FAILSAFE_DRIVER_NAME; static const struct rte_eth_link eth_link = { .link_speed = ETH_SPEED_NUM_10G, @@ -304,7 +306,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) strlen(rte_vdev_device_args(vdev)) == 0) { eth_dev = rte_eth_dev_attach_secondary(name); if (!eth_dev) { - RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + ERROR("Failed to probe %s", name); return -1; } /* TODO: request info from primary to set up Rx and Tx */ @@ -332,3 +334,12 @@ static struct rte_vdev_driver failsafe_drv = { RTE_PMD_REGISTER_VDEV(net_failsafe, failsafe_drv); RTE_PMD_REGISTER_PARAM_STRING(net_failsafe, PMD_FAILSAFE_PARAM_STRING); + +RTE_INIT(failsafe_init_log); +static void +failsafe_init_log(void) +{ + failsafe_logtype = rte_log_register("pmd.net.failsafe"); + if (failsafe_logtype >= 0) + rte_log_set_level(failsafe_logtype, RTE_LOG_NOTICE); +} diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 7db9eebe3f..b54f8e3367 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -326,8 +326,12 @@ extern int mac_from_arg; #define FS_THREADID_FMT "lu" #endif -#define LOG__(level, m, ...) \ - RTE_LOG(level, PMD, "net_failsafe: " m "%c", __VA_ARGS__) +extern int failsafe_logtype; + +#define LOG__(l, m, ...) \ + rte_log(RTE_LOG_ ## l, failsafe_logtype, \ + "net_failsafe: " m "%c", __VA_ARGS__) + #define LOG_(level, ...) LOG__(level, __VA_ARGS__, '\n') #define DEBUG(...) LOG_(DEBUG, __VA_ARGS__) #define INFO(...) LOG_(INFO, __VA_ARGS__)