KNX IoT
KNX IoT Point API stack implementation
oc_log.h File Reference

platform abstraction of logging More...

#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Macros

#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__)
 

Detailed Description

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.

Macro Definition Documentation

◆ 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 "); \
}; \
if ((endpoint).flags & MULTICAST) { \
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 "); \
}; \
if ((endpoint).flags & ACCEPTED) { \
PRINT(" ACCEPTED "); \
}; \
if ((endpoint).flags & OSCORE_DECRYPTED) { \
PRINT(" OSCORE_DECRYPTED "); \
}; \
PRINT(" \n"); \
} while (0)
@ SECURED
secure communication
Definition: oc_endpoint.h:61
@ MULTICAST
multicast enabled
Definition: oc_endpoint.h:66
@ ACCEPTED
accepted
Definition: oc_endpoint.h:67
@ OSCORE_DECRYPTED
OSCORE decrypted message.
Definition: oc_endpoint.h:68
@ TCP
tcp communication
Definition: oc_endpoint.h:64
@ OSCORE
OSCORE communication.
Definition: oc_endpoint.h:65
@ IPV4
ipv4 communication
Definition: oc_endpoint.h:62
@ IPV6
ipv6 communication
Definition: oc_endpoint.h:63

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.