From: jihwan.seo Date: Sat, 11 Feb 2017 04:00:07 +0000 (+0900) Subject: Provide OCSetLogLevel API in CAUtil for C SDK/C++ SDK. X-Git-Tag: 1.3.0~605 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fa40afeaecad3b53da984ca1f11ee218a89a377;p=platform%2Fupstream%2Fiotivity.git Provide OCSetLogLevel API in CAUtil for C SDK/C++ SDK. Change-Id: Ib6a60f1f89c27bdf18f91a1f4fd9c5e87a83d246 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/17199 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai --- diff --git a/resource/csdk/connectivity/api/cacommon.h b/resource/csdk/connectivity/api/cacommon.h index 089f67b..319200b 100755 --- a/resource/csdk/connectivity/api/cacommon.h +++ b/resource/csdk/connectivity/api/cacommon.h @@ -658,6 +658,12 @@ typedef struct extern CAGlobals_t caglobals; +typedef enum +{ + CA_LOG_LEVEL_ALL = 1, // all logs. + CA_LOG_LEVEL_INFO, // debug level is disabled. +} CAUtilLogLevel_t; + /** * Callback function type for request delivery. * @param[out] object Endpoint object from which the request is received. diff --git a/resource/csdk/connectivity/api/cautilinterface.h b/resource/csdk/connectivity/api/cautilinterface.h index 5792160..cb48c53 100644 --- a/resource/csdk/connectivity/api/cautilinterface.h +++ b/resource/csdk/connectivity/api/cautilinterface.h @@ -266,6 +266,17 @@ CAResult_t CAUtilSetBTConfigure(CAUtilConfig_t config); */ CAResult_t CAGetIpv6AddrScope(const char *addr, CATransportFlags_t *scopeLevel); +/** + * set CAUtil log preference. + * @param[in] level ::CAUtilLogLevel_t value + * @param[in] hidePrivateLogEntries Private Log Entries. + * Example: + * true : hide private log. + * false : show private log. + * (privacy : uid, did, access token, etc) + */ +void CAUtilSetLogLevel(CAUtilLogLevel_t level, bool hidePrivateLogEntries); + #ifdef __cplusplus } /* extern "C" */ #endif //__cplusplus diff --git a/resource/csdk/connectivity/util/src/cautilinterface.c b/resource/csdk/connectivity/util/src/cautilinterface.c index 34cd8a0..4cdefe4 100644 --- a/resource/csdk/connectivity/util/src/cautilinterface.c +++ b/resource/csdk/connectivity/util/src/cautilinterface.c @@ -389,3 +389,21 @@ CAResult_t CAGetIpv6AddrScope(const char *addr, CATransportFlags_t *scopeLevel) { return CAGetIpv6AddrScopeInternal(addr, scopeLevel); } + +void CAUtilSetLogLevel(CAUtilLogLevel_t level, bool hidePrivateLogEntries) +{ + OIC_LOG(DEBUG, TAG, "CAUtilSetLogLevel"); + LogLevel logLevel = DEBUG; + switch(level) + { + case CA_LOG_LEVEL_INFO: + logLevel = INFO; + break; + case CA_LOG_LEVEL_ALL: + default: + logLevel = DEBUG; + break; + } + + OCSetLogLevel(logLevel, hidePrivateLogEntries); +} diff --git a/resource/csdk/include/octypes.h b/resource/csdk/include/octypes.h index dcc3e18..8f13f1d 100755 --- a/resource/csdk/include/octypes.h +++ b/resource/csdk/include/octypes.h @@ -692,6 +692,18 @@ typedef enum } OCTransportBTFlags_t; /** + * Log level to print can be controlled through this enum. + * And privacy logs contained uid, Token, Device id, etc can also disable. + * This enum (OCLogLevel) must be kept synchronized with + * CAUtilLogLevel_t (in CACommon.h). + */ +typedef enum +{ + OC_LOG_LEVEL_ALL = 1, // all logs. + OC_LOG_LEVEL_INFO, // debug level is disabled. +} OCLogLevel; + +/** * Enum layout assumes some targets have 16-bit integer (e.g., Arduino). */ typedef enum diff --git a/resource/include/CAManager.h b/resource/include/CAManager.h index f5ac8a5..2a8ac4f 100644 --- a/resource/include/CAManager.h +++ b/resource/include/CAManager.h @@ -110,6 +110,17 @@ namespace OC */ OCStackResult setBTConfigure(const CAUtilConfig& config); + /** + * set CAUtil log preference. + * @param[in] level ::OCLogLevel value. + * @param[in] hidePrivateLogEntries Private Log Entries. + * Example: + * true : hide private log. + * false : show private log. + * (privacy : uid, did, access token, etc) + */ + void setLogLevel(OCLogLevel level, bool hidePrivateLogEntries); + #if defined(__WITH_DTLS__) || defined(__WITH_TLS__) /** * Select the cipher suite for TLS/DTLS handshake. diff --git a/resource/src/CAManager.cpp b/resource/src/CAManager.cpp index 127db0c..8687ce1 100644 --- a/resource/src/CAManager.cpp +++ b/resource/src/CAManager.cpp @@ -139,6 +139,12 @@ OCStackResult CAManager::setBTConfigure(const CAUtilConfig& config) return convertCAResultToOCResult(ret); } +void CAManager::setLogLevel(OCLogLevel level, bool hidePrivateLogEntries) +{ + OIC_LOG(INFO, TAG, "setLogLevel"); + CAUtilSetLogLevel((CAUtilLogLevel_t) level, hidePrivateLogEntries); +} + #if defined(__WITH_DTLS__) || defined(__WITH_TLS__) OCStackResult CAManager::setCipherSuite(const uint16_t cipher, OCTransportAdapter adapter) {