diff --git a/apps/blemesh_shell/src/main.c b/apps/blemesh_shell/src/main.c index fb9c9e691..ee6f763e7 100644 --- a/apps/blemesh_shell/src/main.c +++ b/apps/blemesh_shell/src/main.c @@ -17,8 +17,6 @@ * under the License. */ -#define MESH_LOG_MODULE BLE_MESH_LOG - #include #include "os/mynewt.h" #include "mesh/mesh.h" diff --git a/nimble/host/include/host/ble_hs_log.h b/nimble/host/include/host/ble_hs_log.h index a89b1e662..3e1ded4cd 100644 --- a/nimble/host/include/host/ble_hs_log.h +++ b/nimble/host/include/host/ble_hs_log.h @@ -20,6 +20,12 @@ #ifndef H_BLE_HS_LOG_ #define H_BLE_HS_LOG_ +#ifndef BLE_NPL_LOG_MODULE +#define BLE_NPL_LOG_MODULE BLE_HS_LOG +#endif + +#include + /** * @file ble_hs_log.h * @@ -33,14 +39,6 @@ * @{ */ -#include "modlog/modlog.h" -#include "log/log.h" - -/* Only include the logcfg header if this version of newt can generate it. */ -#if MYNEWT_VAL(NEWT_FEATURE_LOGCFG) -#include "logcfg/logcfg.h" -#endif - #ifdef __cplusplus extern "C" { #endif @@ -57,7 +55,7 @@ struct os_mbuf; * @param ... The format string and additional arguments for the log message. */ #define BLE_HS_LOG(lvl, ...) \ - BLE_HS_LOG_ ## lvl(__VA_ARGS__) + BLE_NPL_LOG(lvl, __VA_ARGS__) /** * @brief Macro for logging a Bluetooth address at a specified log level. @@ -69,9 +67,9 @@ struct os_mbuf; * @param addr The Bluetooth address to be logged. */ #define BLE_HS_LOG_ADDR(lvl, addr) \ - BLE_HS_LOG_ ## lvl("%02x:%02x:%02x:%02x:%02x:%02x", \ - (addr)[5], (addr)[4], (addr)[3], \ - (addr)[2], (addr)[1], (addr)[0]) + BLE_NPL_LOG(lvl, "%02x:%02x:%02x:%02x:%02x:%02x", \ + (addr)[5], (addr)[4], (addr)[3], \ + (addr)[2], (addr)[1], (addr)[0]) /** diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h index 36b82cf5d..de36e6fbb 100644 --- a/nimble/host/mesh/include/mesh/glue.h +++ b/nimble/host/mesh/include/mesh/glue.h @@ -24,8 +24,6 @@ #include #include "syscfg/syscfg.h" -#include "logcfg/logcfg.h" -#include "modlog/modlog.h" #include "nimble/nimble_npl.h" #include "os/os_mbuf.h" @@ -182,19 +180,10 @@ extern "C" { #define BT_GAP_ADV_SLOW_INT_MIN 0x0640 /* 1 s */ #define BT_GAP_ADV_SLOW_INT_MAX 0x0780 /* 1.2 s */ -#ifndef MESH_LOG_MODULE -#define MESH_LOG_MODULE BLE_MESH_LOG -#endif - -#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__) -#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__ - -#define BLE_MESH_LOG(lvl, ...) CAT(MESH_LOG_MODULE, CAT(_, lvl))(__VA_ARGS__) - -#define BT_DBG(fmt, ...) BLE_MESH_LOG(DEBUG, "%s: " fmt "\n", __func__, ## __VA_ARGS__); -#define BT_INFO(fmt, ...) BLE_MESH_LOG(INFO, "%s: " fmt "\n", __func__, ## __VA_ARGS__); -#define BT_WARN(fmt, ...) BLE_MESH_LOG(WARN, "%s: " fmt "\n", __func__, ## __VA_ARGS__); -#define BT_ERR(fmt, ...) BLE_MESH_LOG(ERROR, "%s: " fmt "\n", __func__, ## __VA_ARGS__); +#define BT_DBG(fmt, ...) BLE_NPL_LOG(DEBUG, "%s: " fmt "\n", __func__, ## __VA_ARGS__); +#define BT_INFO(fmt, ...) BLE_NPL_LOG(INFO, "%s: " fmt "\n", __func__, ## __VA_ARGS__); +#define BT_WARN(fmt, ...) BLE_NPL_LOG(WARN, "%s: " fmt "\n", __func__, ## __VA_ARGS__); +#define BT_ERR(fmt, ...) BLE_NPL_LOG(ERROR, "%s: " fmt "\n", __func__, ## __VA_ARGS__); #define BT_GATT_ERR(_att_err) (-(_att_err)) typedef ble_addr_t bt_addr_le_t; diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c index 2c07b0947..40395fe44 100644 --- a/nimble/host/mesh/src/access.c +++ b/nimble/host/mesh/src/access.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_ACCESS_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_ACCESS_LOG +#include #include #include diff --git a/nimble/host/mesh/src/adv.c b/nimble/host/mesh/src/adv.c index d7a8c123c..b2c54ae92 100644 --- a/nimble/host/mesh/src/adv.c +++ b/nimble/host/mesh/src/adv.c @@ -8,7 +8,8 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_ADV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_ADV_LOG +#include #include "mesh/mesh.h" #include "host/ble_hs_adv.h" diff --git a/nimble/host/mesh/src/adv_ext.c b/nimble/host/mesh/src/adv_ext.c index 07c693dea..c5689e565 100644 --- a/nimble/host/mesh/src/adv_ext.c +++ b/nimble/host/mesh/src/adv_ext.c @@ -7,8 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_ADV_LOG - +#define BLE_NPL_LOG_MODULE BLE_MESH_ADV_LOG +#include #include "adv.h" #include "net.h" diff --git a/nimble/host/mesh/src/adv_legacy.c b/nimble/host/mesh/src/adv_legacy.c index 26865058e..6d6a666df 100644 --- a/nimble/host/mesh/src/adv_legacy.c +++ b/nimble/host/mesh/src/adv_legacy.c @@ -7,7 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_ADV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_ADV_LOG +#include #include "adv.h" #include "net.h" diff --git a/nimble/host/mesh/src/aes-ccm.c b/nimble/host/mesh/src/aes-ccm.c index ab23c2644..4814438b3 100644 --- a/nimble/host/mesh/src/aes-ccm.c +++ b/nimble/host/mesh/src/aes-ccm.c @@ -5,8 +5,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include + #include "crypto.h" -#define MESH_LOG_MODULE BLE_MESH_LOG static inline void xor16(uint8_t *dst, const uint8_t *a, const uint8_t *b) { diff --git a/nimble/host/mesh/src/app_keys.c b/nimble/host/mesh/src/app_keys.c index cfe82576a..ab7ab0597 100644 --- a/nimble/host/mesh/src/app_keys.c +++ b/nimble/host/mesh/src/app_keys.c @@ -5,6 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include + #include #include #include "mesh/mesh.h" @@ -21,10 +24,6 @@ #include "access.h" #include "subnet.h" -#define MESH_LOG_MODULE BLE_MESH_LOG - -#include "log/log.h" - /* Tracking of what storage changes are pending for App Keys. We track this in * a separate array here instead of within the respective bt_mesh_app_key * struct itselve, since once a key gets deleted its struct becomes invalid diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c index 2b678f900..e646fc6a3 100644 --- a/nimble/host/mesh/src/beacon.c +++ b/nimble/host/mesh/src/beacon.c @@ -7,7 +7,10 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_BEACON_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_BEACON_LOG +#include + #include #include diff --git a/nimble/host/mesh/src/cdb.c b/nimble/host/mesh/src/cdb.c index 98084ee3d..ed97ce539 100644 --- a/nimble/host/mesh/src/cdb.c +++ b/nimble/host/mesh/src/cdb.c @@ -4,8 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_LOG -#include "log/log.h" +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include + #include #include "cdb_priv.h" diff --git a/nimble/host/mesh/src/cfg.c b/nimble/host/mesh/src/cfg.c index 282aefaf4..122ab4dc7 100644 --- a/nimble/host/mesh/src/cfg.c +++ b/nimble/host/mesh/src/cfg.c @@ -4,6 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include + #include "mesh/mesh.h" #include "mesh_priv.h" #include "net.h" @@ -15,9 +18,6 @@ #include "cfg.h" #include "mesh/glue.h" -#define MESH_LOG_MODULE BLE_MESH_LOG -#include "log/log.h" - /* Miscellaneous configuration server model states */ struct cfg_val { uint8_t net_transmit; diff --git a/nimble/host/mesh/src/cfg_cli.c b/nimble/host/mesh/src/cfg_cli.c index 2a68b40a1..6195f2ac2 100644 --- a/nimble/host/mesh/src/cfg_cli.c +++ b/nimble/host/mesh/src/cfg_cli.c @@ -7,7 +7,10 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include + #if MYNEWT_VAL(BLE_MESH_CFG_CLI) #include "mesh/mesh.h" diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c index cdbd0400c..2b4c046cb 100644 --- a/nimble/host/mesh/src/cfg_srv.c +++ b/nimble/host/mesh/src/cfg_srv.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include #include #include diff --git a/nimble/host/mesh/src/crypto.c b/nimble/host/mesh/src/crypto.c index 3111a6efa..79378da92 100644 --- a/nimble/host/mesh/src/crypto.c +++ b/nimble/host/mesh/src/crypto.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_CRYPTO_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_CRYPTO_LOG +#include #include #include diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c index 4ce0bbdec..2c99d8d71 100644 --- a/nimble/host/mesh/src/friend.c +++ b/nimble/host/mesh/src/friend.c @@ -7,7 +7,10 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_FRIEND_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_FRIEND_LOG +#include + #if MYNEWT_VAL(BLE_MESH_FRIEND) diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index bcacf833c..7dfcaa349 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -18,7 +18,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include #include "mesh/glue.h" #include "adv.h" diff --git a/nimble/host/mesh/src/health_cli.c b/nimble/host/mesh/src/health_cli.c index caa70215b..7765cf11b 100644 --- a/nimble/host/mesh/src/health_cli.c +++ b/nimble/host/mesh/src/health_cli.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include #include #include diff --git a/nimble/host/mesh/src/health_srv.c b/nimble/host/mesh/src/health_srv.c index 4065d24f8..0ea81380e 100644 --- a/nimble/host/mesh/src/health_srv.c +++ b/nimble/host/mesh/src/health_srv.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include #include #include diff --git a/nimble/host/mesh/src/heartbeat.c b/nimble/host/mesh/src/heartbeat.c index faf2f7661..8d15d7642 100644 --- a/nimble/host/mesh/src/heartbeat.c +++ b/nimble/host/mesh/src/heartbeat.c @@ -4,7 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_HEARTBEAT_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_HEARTBEAT_LOG +#include #include "mesh_priv.h" #include "net.h" diff --git a/nimble/host/mesh/src/lpn.c b/nimble/host/mesh/src/lpn.c index 6e164c135..13eb7d138 100644 --- a/nimble/host/mesh/src/lpn.c +++ b/nimble/host/mesh/src/lpn.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_LOW_POWER_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_LOW_POWER_LOG +#include #if MYNEWT_VAL(BLE_MESH_LOW_POWER) diff --git a/nimble/host/mesh/src/mesh.c b/nimble/host/mesh/src/mesh.c index 6ab71e8b1..d3ffb28d9 100644 --- a/nimble/host/mesh/src/mesh.c +++ b/nimble/host/mesh/src/mesh.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_LOG +#include #include #include diff --git a/nimble/host/mesh/src/model_cli.c b/nimble/host/mesh/src/model_cli.c index 22f9b99ee..72c2fa039 100644 --- a/nimble/host/mesh/src/model_cli.c +++ b/nimble/host/mesh/src/model_cli.c @@ -5,7 +5,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include #include "mesh/mesh.h" #include "mesh/model_cli.h" diff --git a/nimble/host/mesh/src/model_srv.c b/nimble/host/mesh/src/model_srv.c index 96981cbab..02b002fd1 100644 --- a/nimble/host/mesh/src/model_srv.c +++ b/nimble/host/mesh/src/model_srv.c @@ -5,7 +5,10 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_MODEL_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_MODEL_LOG +#include + #include "mesh/mesh.h" #include "mesh/model_srv.h" diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c index 229e40546..15fabb109 100644 --- a/nimble/host/mesh/src/net.c +++ b/nimble/host/mesh/src/net.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_NET_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_NET_LOG +#include #include #include diff --git a/nimble/host/mesh/src/pb_adv.c b/nimble/host/mesh/src/pb_adv.c index 35a02b0dc..19d179c85 100644 --- a/nimble/host/mesh/src/pb_adv.c +++ b/nimble/host/mesh/src/pb_adv.c @@ -8,7 +8,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include #include diff --git a/nimble/host/mesh/src/pb_gatt.c b/nimble/host/mesh/src/pb_gatt.c index 865356eeb..ddf8ed736 100644 --- a/nimble/host/mesh/src/pb_gatt.c +++ b/nimble/host/mesh/src/pb_gatt.c @@ -7,7 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include "mesh/mesh.h" #include "prov.h" diff --git a/nimble/host/mesh/src/pb_gatt_srv.c b/nimble/host/mesh/src/pb_gatt_srv.c index 046c94244..2aecec0ce 100644 --- a/nimble/host/mesh/src/pb_gatt_srv.c +++ b/nimble/host/mesh/src/pb_gatt_srv.c @@ -5,7 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include "mesh_priv.h" #include "adv.h" diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c index cdadbb45b..730061bb1 100644 --- a/nimble/host/mesh/src/prov.c +++ b/nimble/host/mesh/src/prov.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include diff --git a/nimble/host/mesh/src/prov_device.c b/nimble/host/mesh/src/prov_device.c index e9e2d2b12..ba15c175b 100644 --- a/nimble/host/mesh/src/prov_device.c +++ b/nimble/host/mesh/src/prov_device.c @@ -7,7 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include "testing.h" #include "crypto.h" diff --git a/nimble/host/mesh/src/provisioner.c b/nimble/host/mesh/src/provisioner.c index f4278e110..36a20a0cf 100644 --- a/nimble/host/mesh/src/provisioner.c +++ b/nimble/host/mesh/src/provisioner.c @@ -8,7 +8,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_PROV_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_PROV_LOG +#include #include "testing.h" diff --git a/nimble/host/mesh/src/proxy_msg.c b/nimble/host/mesh/src/proxy_msg.c index 44613af16..e3aff5627 100644 --- a/nimble/host/mesh/src/proxy_msg.c +++ b/nimble/host/mesh/src/proxy_msg.c @@ -8,7 +8,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_PROXY_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_PROXY_LOG +#include #if MYNEWT_VAL(BLE_MESH_PROXY) diff --git a/nimble/host/mesh/src/proxy_srv.c b/nimble/host/mesh/src/proxy_srv.c index 91c87e50f..15939cfea 100644 --- a/nimble/host/mesh/src/proxy_srv.c +++ b/nimble/host/mesh/src/proxy_srv.c @@ -7,7 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_PROXY_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_PROXY_LOG +#include #include "mesh/slist.h" #include "mesh/mesh.h" diff --git a/nimble/host/mesh/src/rpl.c b/nimble/host/mesh/src/rpl.c index 3a54414ce..ffee94a5d 100644 --- a/nimble/host/mesh/src/rpl.c +++ b/nimble/host/mesh/src/rpl.c @@ -7,9 +7,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define MESH_LOG_MODULE BLE_MESH_RPL_LOG +#define BLE_NPL_LOG_MODULE BLE_MESH_RPL_LOG +#include -#include "log/log.h" #include #include "mesh_priv.h" diff --git a/nimble/host/mesh/src/settings.c b/nimble/host/mesh/src/settings.c index cddf025f9..a3b6ae6dc 100644 --- a/nimble/host/mesh/src/settings.c +++ b/nimble/host/mesh/src/settings.c @@ -5,7 +5,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_SETTINGS_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_SETTINGS_LOG +#include #if MYNEWT_VAL(BLE_MESH_SETTINGS) diff --git a/nimble/host/mesh/src/subnet.c b/nimble/host/mesh/src/subnet.c index 9108cc471..d8c27c371 100644 --- a/nimble/host/mesh/src/subnet.c +++ b/nimble/host/mesh/src/subnet.c @@ -6,9 +6,9 @@ */ #include #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_NET_KEYS_LOG -#include "log/log.h" +#define BLE_NPL_LOG_MODULE BLE_MESH_NET_KEYS_LOG +#include #include "crypto.h" #include "adv.h" diff --git a/nimble/host/mesh/src/transport.c b/nimble/host/mesh/src/transport.c index b3c9d5239..10d444201 100644 --- a/nimble/host/mesh/src/transport.c +++ b/nimble/host/mesh/src/transport.c @@ -7,7 +7,9 @@ */ #include "syscfg/syscfg.h" -#define MESH_LOG_MODULE BLE_MESH_TRANS_LOG + +#define BLE_NPL_LOG_MODULE BLE_MESH_TRANS_LOG +#include #include #include diff --git a/nimble/host/src/ble_att_cmd.c b/nimble/host/src/ble_att_cmd.c index 34521954e..4106cd060 100644 --- a/nimble/host/src/ble_att_cmd.c +++ b/nimble/host/src/ble_att_cmd.c @@ -17,6 +17,10 @@ * under the License. */ +#include +#define BLE_NPL_LOG_MODULE BLE_EATT_LOG +#include + #include #include #include "os/os.h" diff --git a/nimble/host/src/ble_eatt.c b/nimble/host/src/ble_eatt.c index ff2b58023..de1c0d715 100644 --- a/nimble/host/src/ble_eatt.c +++ b/nimble/host/src/ble_eatt.c @@ -18,6 +18,8 @@ */ #include "syscfg/syscfg.h" +#define BLE_NPL_LOG_MODULE BLE_EATT_LOG +#include #if MYNEWT_VAL(BLE_EATT_CHAN_NUM) > 0 diff --git a/nimble/host/src/ble_hs_log.c b/nimble/host/src/ble_hs_log.c index 0670dca6e..01f1ea641 100644 --- a/nimble/host/src/ble_hs_log.c +++ b/nimble/host/src/ble_hs_log.c @@ -21,8 +21,6 @@ #include "host/ble_hs.h" #include "host/ble_hs_log.h" -struct log ble_hs_log; - void ble_hs_log_mbuf(const struct os_mbuf *om) { diff --git a/nimble/include/nimble/nimble_npl_log.h b/nimble/include/nimble/nimble_npl_log.h new file mode 100644 index 000000000..1b49054aa --- /dev/null +++ b/nimble/include/nimble/nimble_npl_log.h @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_LOG_H_ +#define _NIMBLE_NPL_LOG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef BLE_NPL_LOG_MODULE +#error "NPL Logging module not specified" +#endif + +/* helper macros */ +#define _BLE_NPL_LOG_CAT(a, ...) _BLE_NPL_LOG_PRIMITIVE_CAT(a, __VA_ARGS__) +#define _BLE_NPL_LOG_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__ + +/* used to generate proper log function call (used by stack) */ +#define BLE_NPL_LOG(lvl, ...) _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, _BLE_NPL_LOG_CAT(_, lvl))(__VA_ARGS__) + +/* Include OS-specific LOG implementation, should provide implementation for + * logging macros used by NiBLE (eg via modlog) or BLE_NPL_LOG_IMPL + * macro implementation that generates required logging functions/macros + */ +#include "nimble/nimble_npl_os_log.h" + +/* generate logging functions for modules, can be macro or function */ +#ifdef BLE_NPL_LOG_IMPL +BLE_NPL_LOG_IMPL(DEBUG); +BLE_NPL_LOG_IMPL(INFO); +BLE_NPL_LOG_IMPL(WARN); +BLE_NPL_LOG_IMPL(ERROR); +BLE_NPL_LOG_IMPL(CRITICAL); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _NIMBLE_NPL_LOG_H_ */ diff --git a/porting/examples/linux/include/logcfg/logcfg.h b/porting/examples/linux/include/logcfg/logcfg.h deleted file mode 100644 index 4fe2ee015..000000000 --- a/porting/examples/linux/include/logcfg/logcfg.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was generated by Apache newt version: 1.11.0-dev - */ - -#ifndef H_MYNEWT_LOGCFG_ -#define H_MYNEWT_LOGCFG_ - -#include "modlog/modlog.h" -#include "log_common/log_common.h" - -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - -#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) -#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) -#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__) -#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__) -#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__) - -#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__) -#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__) -#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__) -#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) -#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) - -#endif diff --git a/porting/examples/linux_blemesh/include/logcfg/logcfg.h b/porting/examples/linux_blemesh/include/logcfg/logcfg.h deleted file mode 100644 index 99afa084f..000000000 --- a/porting/examples/linux_blemesh/include/logcfg/logcfg.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * This file was generated by Apache newt version: 1.11.0-dev - */ - -#ifndef H_MYNEWT_LOGCFG_ -#define H_MYNEWT_LOGCFG_ - -#include "modlog/modlog.h" -#include "log_common/log_common.h" - -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - -#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) -#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) -#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__) -#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__) -#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__) - -#define BLE_MESH_ACCESS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_ACCESS_LOG_INFO(...) MODLOG_INFO(10, __VA_ARGS__) -#define BLE_MESH_ACCESS_LOG_WARN(...) MODLOG_WARN(10, __VA_ARGS__) -#define BLE_MESH_ACCESS_LOG_ERROR(...) MODLOG_ERROR(10, __VA_ARGS__) -#define BLE_MESH_ACCESS_LOG_CRITICAL(...) MODLOG_CRITICAL(10, __VA_ARGS__) -#define BLE_MESH_ACCESS_LOG_DISABLED(...) MODLOG_DISABLED(10, __VA_ARGS__) - -#define BLE_MESH_ADV_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_ADV_LOG_INFO(...) MODLOG_INFO(11, __VA_ARGS__) -#define BLE_MESH_ADV_LOG_WARN(...) MODLOG_WARN(11, __VA_ARGS__) -#define BLE_MESH_ADV_LOG_ERROR(...) MODLOG_ERROR(11, __VA_ARGS__) -#define BLE_MESH_ADV_LOG_CRITICAL(...) MODLOG_CRITICAL(11, __VA_ARGS__) -#define BLE_MESH_ADV_LOG_DISABLED(...) MODLOG_DISABLED(11, __VA_ARGS__) - -#define BLE_MESH_BEACON_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_BEACON_LOG_INFO(...) MODLOG_INFO(12, __VA_ARGS__) -#define BLE_MESH_BEACON_LOG_WARN(...) MODLOG_WARN(12, __VA_ARGS__) -#define BLE_MESH_BEACON_LOG_ERROR(...) MODLOG_ERROR(12, __VA_ARGS__) -#define BLE_MESH_BEACON_LOG_CRITICAL(...) MODLOG_CRITICAL(12, __VA_ARGS__) -#define BLE_MESH_BEACON_LOG_DISABLED(...) MODLOG_DISABLED(12, __VA_ARGS__) - -#define BLE_MESH_CRYPTO_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_CRYPTO_LOG_INFO(...) MODLOG_INFO(13, __VA_ARGS__) -#define BLE_MESH_CRYPTO_LOG_WARN(...) MODLOG_WARN(13, __VA_ARGS__) -#define BLE_MESH_CRYPTO_LOG_ERROR(...) MODLOG_ERROR(13, __VA_ARGS__) -#define BLE_MESH_CRYPTO_LOG_CRITICAL(...) MODLOG_CRITICAL(13, __VA_ARGS__) -#define BLE_MESH_CRYPTO_LOG_DISABLED(...) MODLOG_DISABLED(13, __VA_ARGS__) - -#define BLE_MESH_FRIEND_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_FRIEND_LOG_INFO(...) MODLOG_INFO(14, __VA_ARGS__) -#define BLE_MESH_FRIEND_LOG_WARN(...) MODLOG_WARN(14, __VA_ARGS__) -#define BLE_MESH_FRIEND_LOG_ERROR(...) MODLOG_ERROR(14, __VA_ARGS__) -#define BLE_MESH_FRIEND_LOG_CRITICAL(...) MODLOG_CRITICAL(14, __VA_ARGS__) -#define BLE_MESH_FRIEND_LOG_DISABLED(...) MODLOG_DISABLED(14, __VA_ARGS__) - -#define BLE_MESH_HEARTBEAT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_HEARTBEAT_LOG_INFO(...) MODLOG_INFO(26, __VA_ARGS__) -#define BLE_MESH_HEARTBEAT_LOG_WARN(...) MODLOG_WARN(26, __VA_ARGS__) -#define BLE_MESH_HEARTBEAT_LOG_ERROR(...) MODLOG_ERROR(26, __VA_ARGS__) -#define BLE_MESH_HEARTBEAT_LOG_CRITICAL(...) MODLOG_CRITICAL(26, __VA_ARGS__) -#define BLE_MESH_HEARTBEAT_LOG_DISABLED(...) MODLOG_DISABLED(26, __VA_ARGS__) - -#define BLE_MESH_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_LOG_INFO(...) MODLOG_INFO(9, __VA_ARGS__) -#define BLE_MESH_LOG_WARN(...) MODLOG_WARN(9, __VA_ARGS__) -#define BLE_MESH_LOG_ERROR(...) MODLOG_ERROR(9, __VA_ARGS__) -#define BLE_MESH_LOG_CRITICAL(...) MODLOG_CRITICAL(9, __VA_ARGS__) -#define BLE_MESH_LOG_DISABLED(...) MODLOG_DISABLED(9, __VA_ARGS__) - -#define BLE_MESH_LOW_POWER_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_LOW_POWER_LOG_INFO(...) MODLOG_INFO(15, __VA_ARGS__) -#define BLE_MESH_LOW_POWER_LOG_WARN(...) MODLOG_WARN(15, __VA_ARGS__) -#define BLE_MESH_LOW_POWER_LOG_ERROR(...) MODLOG_ERROR(15, __VA_ARGS__) -#define BLE_MESH_LOW_POWER_LOG_CRITICAL(...) MODLOG_CRITICAL(15, __VA_ARGS__) -#define BLE_MESH_LOW_POWER_LOG_DISABLED(...) MODLOG_DISABLED(15, __VA_ARGS__) - -#define BLE_MESH_MODEL_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_MODEL_LOG_INFO(...) MODLOG_INFO(16, __VA_ARGS__) -#define BLE_MESH_MODEL_LOG_WARN(...) MODLOG_WARN(16, __VA_ARGS__) -#define BLE_MESH_MODEL_LOG_ERROR(...) MODLOG_ERROR(16, __VA_ARGS__) -#define BLE_MESH_MODEL_LOG_CRITICAL(...) MODLOG_CRITICAL(16, __VA_ARGS__) -#define BLE_MESH_MODEL_LOG_DISABLED(...) MODLOG_DISABLED(16, __VA_ARGS__) - -#define BLE_MESH_NET_KEYS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_NET_KEYS_LOG_INFO(...) MODLOG_INFO(23, __VA_ARGS__) -#define BLE_MESH_NET_KEYS_LOG_WARN(...) MODLOG_WARN(23, __VA_ARGS__) -#define BLE_MESH_NET_KEYS_LOG_ERROR(...) MODLOG_ERROR(23, __VA_ARGS__) -#define BLE_MESH_NET_KEYS_LOG_CRITICAL(...) MODLOG_CRITICAL(23, __VA_ARGS__) -#define BLE_MESH_NET_KEYS_LOG_DISABLED(...) MODLOG_DISABLED(23, __VA_ARGS__) - -#define BLE_MESH_NET_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_NET_LOG_INFO(...) MODLOG_INFO(17, __VA_ARGS__) -#define BLE_MESH_NET_LOG_WARN(...) MODLOG_WARN(17, __VA_ARGS__) -#define BLE_MESH_NET_LOG_ERROR(...) MODLOG_ERROR(17, __VA_ARGS__) -#define BLE_MESH_NET_LOG_CRITICAL(...) MODLOG_CRITICAL(17, __VA_ARGS__) -#define BLE_MESH_NET_LOG_DISABLED(...) MODLOG_DISABLED(17, __VA_ARGS__) - -#define BLE_MESH_PROVISIONER_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_PROVISIONER_LOG_INFO(...) MODLOG_INFO(25, __VA_ARGS__) -#define BLE_MESH_PROVISIONER_LOG_WARN(...) MODLOG_WARN(25, __VA_ARGS__) -#define BLE_MESH_PROVISIONER_LOG_ERROR(...) MODLOG_ERROR(25, __VA_ARGS__) -#define BLE_MESH_PROVISIONER_LOG_CRITICAL(...) MODLOG_CRITICAL(25, __VA_ARGS__) -#define BLE_MESH_PROVISIONER_LOG_DISABLED(...) MODLOG_DISABLED(25, __VA_ARGS__) - -#define BLE_MESH_PROV_DEVICE_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_PROV_DEVICE_LOG_INFO(...) MODLOG_INFO(24, __VA_ARGS__) -#define BLE_MESH_PROV_DEVICE_LOG_WARN(...) MODLOG_WARN(24, __VA_ARGS__) -#define BLE_MESH_PROV_DEVICE_LOG_ERROR(...) MODLOG_ERROR(24, __VA_ARGS__) -#define BLE_MESH_PROV_DEVICE_LOG_CRITICAL(...) MODLOG_CRITICAL(24, __VA_ARGS__) -#define BLE_MESH_PROV_DEVICE_LOG_DISABLED(...) MODLOG_DISABLED(24, __VA_ARGS__) - -#define BLE_MESH_PROV_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_PROV_LOG_INFO(...) MODLOG_INFO(18, __VA_ARGS__) -#define BLE_MESH_PROV_LOG_WARN(...) MODLOG_WARN(18, __VA_ARGS__) -#define BLE_MESH_PROV_LOG_ERROR(...) MODLOG_ERROR(18, __VA_ARGS__) -#define BLE_MESH_PROV_LOG_CRITICAL(...) MODLOG_CRITICAL(18, __VA_ARGS__) -#define BLE_MESH_PROV_LOG_DISABLED(...) MODLOG_DISABLED(18, __VA_ARGS__) - -#define BLE_MESH_PROXY_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_PROXY_LOG_INFO(...) MODLOG_INFO(19, __VA_ARGS__) -#define BLE_MESH_PROXY_LOG_WARN(...) MODLOG_WARN(19, __VA_ARGS__) -#define BLE_MESH_PROXY_LOG_ERROR(...) MODLOG_ERROR(19, __VA_ARGS__) -#define BLE_MESH_PROXY_LOG_CRITICAL(...) MODLOG_CRITICAL(19, __VA_ARGS__) -#define BLE_MESH_PROXY_LOG_DISABLED(...) MODLOG_DISABLED(19, __VA_ARGS__) - -#define BLE_MESH_RPL_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_RPL_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_MESH_RPL_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_MESH_RPL_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_MESH_RPL_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_MESH_RPL_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - -#define BLE_MESH_SETTINGS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_SETTINGS_LOG_INFO(...) MODLOG_INFO(20, __VA_ARGS__) -#define BLE_MESH_SETTINGS_LOG_WARN(...) MODLOG_WARN(20, __VA_ARGS__) -#define BLE_MESH_SETTINGS_LOG_ERROR(...) MODLOG_ERROR(20, __VA_ARGS__) -#define BLE_MESH_SETTINGS_LOG_CRITICAL(...) MODLOG_CRITICAL(20, __VA_ARGS__) -#define BLE_MESH_SETTINGS_LOG_DISABLED(...) MODLOG_DISABLED(20, __VA_ARGS__) - -#define BLE_MESH_TRANS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_MESH_TRANS_LOG_INFO(...) MODLOG_INFO(21, __VA_ARGS__) -#define BLE_MESH_TRANS_LOG_WARN(...) MODLOG_WARN(21, __VA_ARGS__) -#define BLE_MESH_TRANS_LOG_ERROR(...) MODLOG_ERROR(21, __VA_ARGS__) -#define BLE_MESH_TRANS_LOG_CRITICAL(...) MODLOG_CRITICAL(21, __VA_ARGS__) -#define BLE_MESH_TRANS_LOG_DISABLED(...) MODLOG_DISABLED(21, __VA_ARGS__) - -#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__) -#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__) -#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__) -#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) -#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) - -#endif diff --git a/porting/examples/nuttx/include/logcfg/logcfg.h b/porting/examples/nuttx/include/logcfg/logcfg.h deleted file mode 100644 index 89af35309..000000000 --- a/porting/examples/nuttx/include/logcfg/logcfg.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This file was generated by Apache newt version: 1.11.0-dev - */ - -#ifndef H_MYNEWT_LOGCFG_ -#define H_MYNEWT_LOGCFG_ - -#include "modlog/modlog.h" -#include "log_common/log_common.h" - -#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) -#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) -#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__) -#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__) -#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__) - -#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__) -#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__) -#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__) -#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) -#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) - -#endif diff --git a/porting/nimble/include/log_common/ignore.h b/porting/nimble/include/log_common/ignore.h deleted file mode 100644 index 46282a029..000000000 --- a/porting/nimble/include/log_common/ignore.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef H_IGNORE_ -#define H_IGNORE_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * These macros prevent the "set but not used" warnings for log writes below - * the log level. - */ - -#define IGN_1(X) ((void)(X)) -#define IGN_2(X, ...) ((void)(X));IGN_1(__VA_ARGS__) -#define IGN_3(X, ...) ((void)(X));IGN_2(__VA_ARGS__) -#define IGN_4(X, ...) ((void)(X));IGN_3(__VA_ARGS__) -#define IGN_5(X, ...) ((void)(X));IGN_4(__VA_ARGS__) -#define IGN_6(X, ...) ((void)(X));IGN_5(__VA_ARGS__) -#define IGN_7(X, ...) ((void)(X));IGN_6(__VA_ARGS__) -#define IGN_8(X, ...) ((void)(X));IGN_7(__VA_ARGS__) -#define IGN_9(X, ...) ((void)(X));IGN_8(__VA_ARGS__) -#define IGN_10(X, ...) ((void)(X));IGN_9(__VA_ARGS__) -#define IGN_11(X, ...) ((void)(X));IGN_10(__VA_ARGS__) -#define IGN_12(X, ...) ((void)(X));IGN_11(__VA_ARGS__) -#define IGN_13(X, ...) ((void)(X));IGN_12(__VA_ARGS__) -#define IGN_14(X, ...) ((void)(X));IGN_13(__VA_ARGS__) -#define IGN_15(X, ...) ((void)(X));IGN_14(__VA_ARGS__) -#define IGN_16(X, ...) ((void)(X));IGN_15(__VA_ARGS__) -#define IGN_17(X, ...) ((void)(X));IGN_16(__VA_ARGS__) -#define IGN_18(X, ...) ((void)(X));IGN_17(__VA_ARGS__) -#define IGN_19(X, ...) ((void)(X));IGN_18(__VA_ARGS__) -#define IGN_20(X, ...) ((void)(X));IGN_19(__VA_ARGS__) - -#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, \ - _13, _14, _15, _16, _17, _18, _19, _20, NAME, ...) NAME -#define IGNORE(...) \ - GET_MACRO(__VA_ARGS__, IGN_20, IGN_19, IGN_18, IGN_17, IGN_16, IGN_15, \ - IGN_14, IGN_13, IGN_12, IGN_11, IGN_10, IGN_9, IGN_8, IGN_7, \ - IGN_6, IGN_5, IGN_4, IGN_3, IGN_2, IGN_1)(__VA_ARGS__) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/porting/nimble/include/log_common/log_common.h b/porting/nimble/include/log_common/log_common.h deleted file mode 100644 index ed590b6b0..000000000 --- a/porting/nimble/include/log_common/log_common.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef H_LOG_COMMON_ -#define H_LOG_COMMON_ - -#include -#include "log_common/ignore.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct log; - -#define LOG_VERSION_V3 3 - -#define LOG_TYPE_STREAM (0) -#define LOG_TYPE_MEMORY (1) -#define LOG_TYPE_STORAGE (2) - -#define LOG_LEVEL_DEBUG (0) -#define LOG_LEVEL_INFO (1) -#define LOG_LEVEL_WARN (2) -#define LOG_LEVEL_ERROR (3) -#define LOG_LEVEL_CRITICAL (4) -/* Up to 10 custom log levels. */ -#define LOG_LEVEL_MAX (15) - -#define LOG_LEVEL_STR(level) \ - (LOG_LEVEL_DEBUG == level ? "DEBUG" :\ - (LOG_LEVEL_INFO == level ? "INFO" :\ - (LOG_LEVEL_WARN == level ? "WARN" :\ - (LOG_LEVEL_ERROR == level ? "ERROR" :\ - (LOG_LEVEL_CRITICAL == level ? "CRITICAL" :\ - "UNKNOWN"))))) - -/* XXX: These module IDs are defined for backwards compatibility. Application - * code should use the syscfg settings directly. These defines will be removed - * in a future release. - */ -#define LOG_MODULE_DEFAULT 0 -#define LOG_MODULE_OS 1 -#define LOG_MODULE_NEWTMGR 2 -#define LOG_MODULE_NIMBLE_CTLR 3 -#define LOG_MODULE_NIMBLE_HOST 4 -#define LOG_MODULE_NFFS 5 -#define LOG_MODULE_REBOOT 6 -#define LOG_MODULE_IOTIVITY 7 -#define LOG_MODULE_TEST 8 - -#define LOG_MODULE_PERUSER 64 -#define LOG_MODULE_MAX (255) - -#define LOG_ETYPE_STRING (0) -#define LOG_ETYPE_CBOR (1) -#define LOG_ETYPE_BINARY (2) - -/* UTC Timestamp for Jan 2016 00:00:00 */ -#define UTC01_01_2016 1451606400 - -#define LOG_NAME_MAX_LEN (64) - -#ifndef MYNEWT_VAL_LOG_LEVEL -#define LOG_SYSLEVEL ((uint8_t)LOG_LEVEL_MAX) -#else -#define LOG_SYSLEVEL ((uint8_t)MYNEWT_VAL_LOG_LEVEL) -#endif - -/** - * @brief Determines if a log module will accept an entry with a given level. - * - * A log entry is only accepted if its level is less than or equal to both: - * o Global log level setting (LOG_LEVEL), and - * o The specified module log level - * - * @param mod_level The module's minimum log level. - * @param entry_level The level of the entry to be logged. - * - * @return true if the entry would be logged; - * false otherwise. - */ -#define LOG_MOD_LEVEL_IS_ACTIVE(mod_level, entry_level) \ - (LOG_LEVEL <= (entry_level) && (mod_level) <= (entry_level)) - -/* Newtmgr Log opcodes */ -#define LOGS_NMGR_OP_READ (0) -#define LOGS_NMGR_OP_CLEAR (1) -#define LOGS_NMGR_OP_APPEND (2) -#define LOGS_NMGR_OP_MODULE_LIST (3) -#define LOGS_NMGR_OP_LEVEL_LIST (4) -#define LOGS_NMGR_OP_LOGS_LIST (5) -#define LOGS_NMGR_OP_SET_WATERMARK (6) -#define LOGS_NMGR_OP_MODLEVEL (8) - -#define LOG_PRINTF_MAX_ENTRY_LEN (128) - -/* Global log info */ -struct log_info { -#if MYNEWT_VAL(LOG_GLOBAL_IDX) - uint32_t li_next_index; -#endif - uint8_t li_version; -}; - -extern struct log_info g_log_info; - -/** @typedef log_append_cb - * @brief Callback that is executed each time the corresponding log is appended - * to. - * - * @param log The log that was just appended to. - * @param idx The index of newly appended log entry. - */ -typedef void log_append_cb(struct log *log, uint32_t idx); - -/** @typdef log_notify_rotate_cb - * @brief Callback that is executed each time we are about to rotate a log. - * - * @param log The log that is about to rotate - */ -typedef void log_notify_rotate_cb(const struct log *log); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/porting/nimble/include/logcfg/logcfg.h b/porting/nimble/include/logcfg/logcfg.h deleted file mode 100644 index 4fe2ee015..000000000 --- a/porting/nimble/include/logcfg/logcfg.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was generated by Apache newt version: 1.11.0-dev - */ - -#ifndef H_MYNEWT_LOGCFG_ -#define H_MYNEWT_LOGCFG_ - -#include "modlog/modlog.h" -#include "log_common/log_common.h" - -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - -#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) -#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) -#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__) -#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__) -#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__) - -#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__) -#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__) -#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__) -#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) -#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) - -#endif diff --git a/porting/nimble/include/modlog/modlog.h b/porting/nimble/include/modlog/modlog.h deleted file mode 100644 index 039046106..000000000 --- a/porting/nimble/include/modlog/modlog.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef H_MODLOG_ -#define H_MODLOG_ - -#include - -#include "log_common/log_common.h" -#include "log/log.h" - -#define MODLOG_MODULE_DFLT 255 - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__ -#define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_DEBUG(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__ -#define MODLOG_INFO(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_INFO(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__ -#define MODLOG_WARN(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_WARN(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__ -#define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_ERROR(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__ -#define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_CRITICAL(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#define MODLOG(ml_lvl_, ml_mod_, ...) \ - MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__) - -#endif diff --git a/porting/npl/dummy/include/nimble/nimble_npl_os_log.h b/porting/npl/dummy/include/nimble/nimble_npl_os_log.h new file mode 100644 index 000000000..7391c7435 --- /dev/null +++ b/porting/npl/dummy/include/nimble/nimble_npl_os_log.h @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ + +#define BLE_NPL_LOG_IMPL(lvl) \ + static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ + _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...) { } + +#endif /* _NIMBLE_NPL_OS_LOG_H_ */ diff --git a/porting/npl/freertos/include/nimble/nimble_npl_os_log.h b/porting/npl/freertos/include/nimble/nimble_npl_os_log.h new file mode 100644 index 000000000..5fcce6aee --- /dev/null +++ b/porting/npl/freertos/include/nimble/nimble_npl_os_log.h @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ + +#include + +/* Example on how to use macro to generate module logging functions */ +#define BLE_NPL_LOG_IMPL(lvl) \ + static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ + _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\ + { \ + va_list args; \ + va_start(args, fmt); \ + vprintf(fmt, args); \ + va_end(args); \ + } + +#endif /* _NIMBLE_NPL_OS_LOG_H_ */ diff --git a/porting/npl/linux/include/nimble/nimble_npl_os_log.h b/porting/npl/linux/include/nimble/nimble_npl_os_log.h new file mode 100644 index 000000000..24315a21a --- /dev/null +++ b/porting/npl/linux/include/nimble/nimble_npl_os_log.h @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ + +#include +#include + +/* Example on how to use macro to generate module logging functions */ +#define BLE_NPL_LOG_IMPL(lvl) \ + static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ + _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\ + { \ + va_list args; \ + va_start(args, fmt); \ + vprintf(fmt, args); \ + va_end(args); \ + } + +#endif /* _NIMBLE_NPL_OS_LOG_H_ */ diff --git a/porting/nimble/include/log/log.h b/porting/npl/mynewt/include/nimble/nimble_npl_os_log.h similarity index 58% rename from porting/nimble/include/log/log.h rename to porting/npl/mynewt/include/nimble/nimble_npl_os_log.h index be9237c52..3ec47344a 100644 --- a/porting/nimble/include/log/log.h +++ b/porting/npl/mynewt/include/nimble/nimble_npl_os_log.h @@ -17,32 +17,15 @@ * under the License. */ -#ifndef __LOG_H__ -#define __LOG_H__ +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ -#ifdef __cplusplus -extern "C" { +#include +#include + +/* Only include the logcfg header if this version of newt can generate it. */ +#if MYNEWT_VAL(NEWT_FEATURE_LOGCFG) +#include #endif -static inline void -log_dummy(void *log, ...) -{ - (void)log; -} - -#ifdef MYNEWT -#define LOG_DEBUG(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__) -#define LOG_INFO(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__) -#define LOG_WARN(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__) -#define LOG_ERROR(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__) -#define LOG_CRITICAL(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__) -#endif - -struct log { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* __LOG_H__ */ +#endif /* _NIMBLE_NPL_OS_LOG_H_ */ diff --git a/porting/npl/nuttx/include/modlog/modlog.h b/porting/npl/nuttx/include/modlog/modlog.h deleted file mode 100644 index 5e51b5010..000000000 --- a/porting/npl/nuttx/include/modlog/modlog.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef H_MODLOG_ -#define H_MODLOG_ - -#include -#include - -#include "log_common/log_common.h" - -#define MODLOG_MODULE_DFLT 255 - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__ -#define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_DEBUG(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__ -#define MODLOG_INFO(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_INFO(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__ -#define MODLOG_WARN(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_WARN(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__ -#define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_ERROR(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__ -#define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \ - printf((ml_msg_), ##__VA_ARGS__) -#else -#define MODLOG_CRITICAL(ml_mod_, ...) IGNORE(__VA_ARGS__) -#endif - -#define MODLOG(ml_lvl_, ml_mod_, ...) \ - MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__) - -#endif diff --git a/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h b/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h new file mode 100644 index 000000000..5fcce6aee --- /dev/null +++ b/porting/npl/nuttx/include/nimble/nimble_npl_os_log.h @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ + +#include + +/* Example on how to use macro to generate module logging functions */ +#define BLE_NPL_LOG_IMPL(lvl) \ + static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ + _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\ + { \ + va_list args; \ + va_start(args, fmt); \ + vprintf(fmt, args); \ + va_end(args); \ + } + +#endif /* _NIMBLE_NPL_OS_LOG_H_ */ diff --git a/porting/npl/riot/include/logcfg/logcfg.h b/porting/npl/riot/include/logcfg/logcfg.h deleted file mode 100644 index 4fe2ee015..000000000 --- a/porting/npl/riot/include/logcfg/logcfg.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was generated by Apache newt version: 1.11.0-dev - */ - -#ifndef H_MYNEWT_LOGCFG_ -#define H_MYNEWT_LOGCFG_ - -#include "modlog/modlog.h" -#include "log_common/log_common.h" - -#define BLE_EATT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_EATT_LOG_INFO(...) MODLOG_INFO(22, __VA_ARGS__) -#define BLE_EATT_LOG_WARN(...) MODLOG_WARN(22, __VA_ARGS__) -#define BLE_EATT_LOG_ERROR(...) MODLOG_ERROR(22, __VA_ARGS__) -#define BLE_EATT_LOG_CRITICAL(...) MODLOG_CRITICAL(22, __VA_ARGS__) -#define BLE_EATT_LOG_DISABLED(...) MODLOG_DISABLED(22, __VA_ARGS__) - -#define BLE_HS_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define BLE_HS_LOG_INFO(...) MODLOG_INFO(4, __VA_ARGS__) -#define BLE_HS_LOG_WARN(...) MODLOG_WARN(4, __VA_ARGS__) -#define BLE_HS_LOG_ERROR(...) MODLOG_ERROR(4, __VA_ARGS__) -#define BLE_HS_LOG_CRITICAL(...) MODLOG_CRITICAL(4, __VA_ARGS__) -#define BLE_HS_LOG_DISABLED(...) MODLOG_DISABLED(4, __VA_ARGS__) - -#define DFLT_LOG_DEBUG(...) IGNORE(__VA_ARGS__) -#define DFLT_LOG_INFO(...) MODLOG_INFO(0, __VA_ARGS__) -#define DFLT_LOG_WARN(...) MODLOG_WARN(0, __VA_ARGS__) -#define DFLT_LOG_ERROR(...) MODLOG_ERROR(0, __VA_ARGS__) -#define DFLT_LOG_CRITICAL(...) MODLOG_CRITICAL(0, __VA_ARGS__) -#define DFLT_LOG_DISABLED(...) MODLOG_DISABLED(0, __VA_ARGS__) - -#endif diff --git a/porting/npl/riot/include/nimble/nimble_npl_os_log.h b/porting/npl/riot/include/nimble/nimble_npl_os_log.h new file mode 100644 index 000000000..5fcce6aee --- /dev/null +++ b/porting/npl/riot/include/nimble/nimble_npl_os_log.h @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _NIMBLE_NPL_OS_LOG_H_ +#define _NIMBLE_NPL_OS_LOG_H_ + +#include + +/* Example on how to use macro to generate module logging functions */ +#define BLE_NPL_LOG_IMPL(lvl) \ + static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ + _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\ + { \ + va_list args; \ + va_start(args, fmt); \ + vprintf(fmt, args); \ + va_end(args); \ + } + +#endif /* _NIMBLE_NPL_OS_LOG_H_ */