platform abstraction of logging
More...
#include <stdio.h>
#include <string.h>
Go to the source code of this file.
|
#define | __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) |
|
#define | IPADDR_BUFF_SIZE 64 |
|
#define | OC_DBG(...) OC_LOG("D", __VA_ARGS__) |
|
#define | OC_DBG_OSCORE(...) |
|
#define | OC_DBG_SPAKE(...) |
|
#define | OC_ERR(...) OC_LOG("E", __VA_ARGS__) |
|
#define | OC_ERR(...) OC_LOG("E", __VA_ARGS__) |
|
#define | OC_LOG(level, ...) |
|
#define | OC_LOGbytes(bytes, length) |
|
#define | OC_LOGbytes_internal(prefix, bytes, length) |
|
#define | OC_LOGbytes_internalxx(prefix, bytes, length) |
|
#define | OC_LOGbytes_OSCORE(bytes, length) |
|
#define | OC_LOGbytes_SPAKE(bytes, length) |
|
#define | OC_LOGipaddr(endpoint) |
|
#define | OC_WRN(...) OC_LOG("W", __VA_ARGS__) |
|
#define | OC_WRN(...) OC_LOG("W", __VA_ARGS__) |
|
#define | PRINT(...) |
|
#define | PRINT_APP(...) |
|
#define | PRINTipaddr(endpoint) |
|
#define | PRINTipaddr_flags(endpoint) |
|
#define | PRINTipaddr_local(endpoint) |
|
#define | SNPRINTF(...) snprintf(__VA_ARGS__) |
|
#define | SNPRINTFbytes(buff, size, data, len) |
|
#define | SNPRINTFipaddr(str, size, endpoint) |
|
#define | SPRINTF(...) sprintf(__VA_ARGS__) |
|
platform abstraction of logging
generic logging functions:
- OC_LOGipaddr prints the endpoint information to stdout
- OC_LOGbytes prints the bytes to stdout
- OC_DBG prints information as Debug level
- OC_WRN prints information as Warning level
- OC_ERR prints information as Error level
compile flags:
- OC_DEBUG enables output of logging functions
- OC_NO_LOG_BYTES disables output of OC_LOGbytes logging function if OC_DEBUG is enabled.
- OC_LOG_TO_FILE logs the PRINT statements to file
Definition in file oc_log.h.
◆ OC_LOG
#define OC_LOG |
( |
|
level, |
|
|
|
... |
|
) |
| |
Value: do { \
PRINT("%s: %s <%s:%d>: ", level, __FILENAME__, __func__, __LINE__); \
PRINT(__VA_ARGS__); \
PRINT("\n"); \
} while (0)
Definition at line 241 of file oc_log.h.
◆ OC_LOGbytes
#define OC_LOGbytes |
( |
|
bytes, |
|
|
|
length |
|
) |
| |
Value: do { \
PRINT("D: %s <%s:%d>: ", __FILENAME__, __func__, __LINE__); \
uint16_t i; \
for (i = 0; i < (length); i++) \
PRINT(" %02X", (bytes)[i]); \
PRINT("\n"); \
} while (0)
Definition at line 291 of file oc_log.h.
◆ OC_LOGbytes_internal
#define OC_LOGbytes_internal |
( |
|
prefix, |
|
|
|
bytes, |
|
|
|
length |
|
) |
| |
Value: do { \
uint16_t i; \
for (i = 0; i < (length); i++) \
PRINT(" %02X", (bytes)[i]); \
PRINT("\n"); \
} while (0)
Definition at line 257 of file oc_log.h.
◆ OC_LOGbytes_internalxx
#define OC_LOGbytes_internalxx |
( |
|
prefix, |
|
|
|
bytes, |
|
|
|
length |
|
) |
| |
Value: do { \
PRINT("%s: %s <%s:%d>:\n", prefix, __FILENAME__, __func__, __LINE__); \
uint16_t i; \
for (i = 0; i < (length); i++) \
PRINT(" %02X", (bytes)[i]); \
PRINT("\n"); \
} while (0)
Definition at line 248 of file oc_log.h.
◆ OC_LOGipaddr
#define OC_LOGipaddr |
( |
|
endpoint | ) |
|
Value: do { \
PRINT("DEBUG: %s <%s:%d>: ", __FILENAME__, __func__, __LINE__); \
PRINTipaddr(endpoint); \
PRINT("\n"); \
} while (0)
Definition at line 283 of file oc_log.h.
◆ PRINTipaddr_flags
#define PRINTipaddr_flags |
( |
|
endpoint | ) |
|
Value: do { \
if ((endpoint).flags &
SECURED) { \
PRINT(" Secured "); \
}; \
PRINT(" MULTICAST "); \
}; \
if ((endpoint).flags &
TCP) { \
PRINT(" TCP "); \
}; \
if ((endpoint).flags &
IPV4) { \
PRINT(" IPV4 "); \
}; \
if ((endpoint).flags &
IPV6) { \
PRINT(" IPV6 "); \
}; \
if ((endpoint).flags &
OSCORE) { \
PRINT(" OSCORE "); \
}; \
PRINT(" ACCEPTED "); \
}; \
PRINT(" OSCORE_DECRYPTED "); \
}; \
PRINT(" \n"); \
} while (0)
@ SECURED
secure communication
@ MULTICAST
multicast enabled
@ OSCORE_DECRYPTED
OSCORE decrypted message.
@ OSCORE
OSCORE communication.
Definition at line 122 of file oc_log.h.
◆ SNPRINTFbytes
#define SNPRINTFbytes |
( |
|
buff, |
|
|
|
size, |
|
|
|
data, |
|
|
|
len |
|
) |
| |
Value: do { \
char *beg = (buff); \
char *end = (buff) + (size); \
for (size_t i = 0; beg <= (end - 3) && i < (len); i++) { \
beg += (i == 0) ? SPRINTF(beg, "%02x", (data)[i]) \
: SPRINTF(beg, ":%02x", (data)[i]); \
} \
} while (0)
Definition at line 231 of file oc_log.h.