#endif
#ifdef __TIZEN__
-#define OCLog(level,tag,mes)
-#define OCLogv(level,tag,fmt,args...)
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param[in] level DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param[in] tag Module name
+ * @param[in] buffer pointer to buffer of bytes
+ * @param[in] bufferSize max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize);
+
+#define OCLog(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
+#define OCLogv(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, (level),tag,fmt,##args)
#elif defined(ANDROID) || defined(__linux__) || defined(__APPLE__)
/**
* Configure logger to use a context that defines a custom logger function
#define OIC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
#define OIC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt, ##args)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\
+ OCLogBuffer((level), (tag), (buffer), (bufferSize))
#else // These macros are defined for Linux, Android, and Arduino
#endif
#endif // __ANDROID__
-
#ifndef ARDUINO
+
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param buffer - pointer to buffer of bytes
+ * @param bufferSize - max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
+{
+ if (!buffer || !tag || (bufferSize == 0))
+ {
+ return;
+ }
+
+ // No idea why the static initialization won't work here, it seems the compiler is convinced
+ // that this is a variable-sized object.
+ char lineBuffer[LINE_BUFFER_SIZE];
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ int lineIndex = 0;
+ int i;
+ for (i = 0; i < bufferSize; i++)
+ {
+ // Format the buffer data into a line
+ snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+ lineIndex++;
+ // Output 16 values per line
+ if (((i+1)%16) == 0)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ lineIndex = 0;
+ }
+ }
+ // Output last values in the line, if any
+ if (bufferSize % 16)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ }
+}
#ifndef __TIZEN__
void OCLogConfig(oc_log_ctx_t *ctx)
{
}
#endif
}
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
-{
- if (!buffer || !tag || (bufferSize == 0))
- {
- return;
- }
-
- // No idea why the static initialization won't work here, it seems the compiler is convinced
- // that this is a variable-sized object.
- char lineBuffer[LINE_BUFFER_SIZE];
- memset(lineBuffer, 0, sizeof lineBuffer);
- int lineIndex = 0;
- int i;
- for (i = 0; i < bufferSize; i++)
- {
- // Format the buffer data into a line
- snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
- lineIndex++;
- // Output 16 values per line
- if (((i+1)%16) == 0)
- {
- OCLog(level, tag, lineBuffer);
- memset(lineBuffer, 0, sizeof lineBuffer);
- lineIndex = 0;
- }
- }
- // Output last values in the line, if any
- if (bufferSize % 16)
- {
- OCLog(level, tag, lineBuffer);
- }
-}
#endif //__TIZEN__
#endif //ARDUINO
#ifdef ARDUINO