From 8a1a67f592be0884edb01a74e485ae058bc828ff Mon Sep 17 00:00:00 2001 From: Tatiana Leon Date: Wed, 10 May 2017 14:31:50 +0200 Subject: [PATCH] aws-iot-sdk: add variable to establish the logging level Variable 'AWS_IOT_LOGGING_LEVEL' can be used from the project 'local.conf' to establish the logging level of the AWS IoT Device SDK. There are 6 incremental levels: none, error, warn, info, debug, and trace. Default is 'debug'. https://jira.digi.com/browse/DEL-4101 Signed-off-by: Tatiana Leon --- meta-digi-dey/classes/awsiotsdk-c.bbclass | 22 +++++++++++++++++++ .../awsiotsdk-c/awsiotsdk-c_2.1.1.bb | 2 ++ 2 files changed, 24 insertions(+) diff --git a/meta-digi-dey/classes/awsiotsdk-c.bbclass b/meta-digi-dey/classes/awsiotsdk-c.bbclass index 2bd560922..1ec839042 100644 --- a/meta-digi-dey/classes/awsiotsdk-c.bbclass +++ b/meta-digi-dey/classes/awsiotsdk-c.bbclass @@ -63,3 +63,25 @@ AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL ?= "1000" # to reconnect (milliseconds) AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL ?= "128000" +# Logging level control: error, warn, info, debug, trace. +AWS_IOT_LOGGING_LEVEL ?= "debug" + +def get_log_level(d): + levels = ['error', 'warn', 'info', 'debug', 'trace'] + log_flags = "" + + log_level = d.getVar('AWS_IOT_LOGGING_LEVEL', True) + if log_level == 'none': + return "" + if log_level not in levels: + log_level = "debug" + d.setVar('AWS_IOT_LOGGING_LEVEL', log_level) + + log_index = levels.index(log_level) + for i, val in enumerate(levels): + log_flags = log_flags + "-DENABLE_IOT_" + val.upper() + " " + if i == log_index: + break; + + return log_flags + diff --git a/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb index 36dd35755..866990ef0 100644 --- a/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb +++ b/meta-digi-dey/recipes-digi/awsiotsdk-c/awsiotsdk-c_2.1.1.bb @@ -24,6 +24,8 @@ S = "${WORKDIR}/aws-iot-device-sdk-embedded-C-${PV}" inherit awsiotsdk-c pkgconfig +EXTRA_OEMAKE += "'LOG_FLAGS=${@get_log_level(d)}'" + do_configure() { cp -f ${WORKDIR}/awsiotsdk.pc ${S}