Provide OCSetLogLevel API in CAUtil for C SDK/C++ SDK.
authorjihwan.seo <jihwan.seo@samsung.com>
Sat, 11 Feb 2017 04:00:07 +0000 (13:00 +0900)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 21 Feb 2017 17:43:08 +0000 (17:43 +0000)
Change-Id: Ib6a60f1f89c27bdf18f91a1f4fd9c5e87a83d246
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17199
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/api/cautilinterface.h
resource/csdk/connectivity/util/src/cautilinterface.c
resource/csdk/include/octypes.h
resource/include/CAManager.h
resource/src/CAManager.cpp

index 089f67b..319200b 100755 (executable)
@@ -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.
index 5792160..cb48c53 100644 (file)
@@ -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
index 34cd8a0..4cdefe4 100644 (file)
@@ -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);
+}
index dcc3e18..8f13f1d 100755 (executable)
@@ -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
index f5ac8a5..2a8ac4f 100644 (file)
@@ -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.
index 127db0c..8687ce1 100644 (file)
@@ -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)
 {