NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Functions
logger.h File Reference
#include "common.h"

Go to the source code of this file.

Data Structures

struct  DebugString
 

Macros

#define RTE_LOG_DP_LEVEL   RTE_LOG_DEBUG
 
#define N_LOG_INIT(module)
 
#define N_LOG(lvl, fmt, ...)   RTE_LOG_DP(lvl, NDN, fmt "\n", ##__VA_ARGS__)
 
#define N_LOGV(...)   N_LOG(DEBUG, __VA_ARGS__)
 
#define N_LOGD(...)   N_LOG(INFO, __VA_ARGS__)
 
#define N_LOGI(...)   N_LOG(NOTICE, __VA_ARGS__)
 
#define N_LOGW(...)   N_LOG(WARNING, __VA_ARGS__)
 
#define N_LOGE(...)   N_LOG(ERR, __VA_ARGS__)
 
#define N_LOG_ERROR(s)   " ERROR={" s "}"
 
#define N_LOG_ERROR_BLANK   N_LOG_ERROR("-")
 
#define N_LOG_ERROR_ERRNO   N_LOG_ERROR("errno<%d>")
 
#define N_LOG_ERROR_STR   N_LOG_ERROR("%s")
 
#define N_LOG_ENABLED(lvl)    (RTE_LOG_DP_LEVEL >= RTE_LOG_##lvl && rte_log_get_level(RTE_LOGTYPE_NDN) >= (int)RTE_LOG_##lvl)
 Determine if a log level is enabled. More...
 
#define DebugString_Use(capacity)   DebugString* myDebugString = DebugString_Get((capacity))
 Declare a debug string variable within a function. More...
 
#define DebugString_Append(fn, ...)
 Append to the local debug string variable. More...
 
#define DebugString_Return()
 Return the buffer in local debug string variable after bounds checking. More...
 

Typedefs

typedef struct DebugString DebugString
 

Functions

int Logger_Dpdk_Init (FILE *output)
 
void Logger_Spdk (int level, const char *restrict file, const int line, const char *restrict func, const char *restrict format, va_list args)
 
void Logger_HexDump (const uint8_t *b, size_t count)
 Print buffer in hexadecimal to stderr. More...
 
DebugStringDebugString_Get (size_t capacity)
 Obtain a buffer for populating a debug string. More...
 

Macro Definition Documentation

◆ DebugString_Append

#define DebugString_Append (   fn,
  ... 
)
Value:
do { \
myDebugString->pos += fn(RTE_PTR_ADD(myDebugString->buffer, myDebugString->pos), \
myDebugString->cap - myDebugString->pos, __VA_ARGS__); \
} while (false)

Append to the local debug string variable.

Parameters
fnsprintf-like function.

◆ DebugString_Return

#define DebugString_Return ( )
Value:
do { \
NDNDPDK_ASSERT(myDebugString->pos < myDebugString->cap); \
return myDebugString->buffer; \
} while (false)

Return the buffer in local debug string variable after bounds checking.

◆ DebugString_Use

#define DebugString_Use (   capacity)    DebugString* myDebugString = DebugString_Get((capacity))

Declare a debug string variable within a function.

◆ N_LOG

#define N_LOG (   lvl,
  fmt,
  ... 
)    RTE_LOG_DP(lvl, NDN, fmt "\n", ##__VA_ARGS__)

◆ N_LOG_ENABLED

#define N_LOG_ENABLED (   lvl)     (RTE_LOG_DP_LEVEL >= RTE_LOG_##lvl && rte_log_get_level(RTE_LOGTYPE_NDN) >= (int)RTE_LOG_##lvl)

Determine if a log level is enabled.

Parameters
lvlone of DEBUG, INFO, NOTICE, WARNING, ERR.

◆ N_LOG_ERROR

#define N_LOG_ERROR (   s)    " ERROR={" s "}"

◆ N_LOG_ERROR_BLANK

#define N_LOG_ERROR_BLANK   N_LOG_ERROR("-")

◆ N_LOG_ERROR_ERRNO

#define N_LOG_ERROR_ERRNO   N_LOG_ERROR("errno<%d>")

◆ N_LOG_ERROR_STR

#define N_LOG_ERROR_STR   N_LOG_ERROR("%s")

◆ N_LOG_INIT

#define N_LOG_INIT (   module)
Value:
static int RTE_LOGTYPE_NDN = -1; \
RTE_INIT(Logger_Init_##module) { \
RTE_LOGTYPE_NDN = rte_log_register_type_and_pick_level("NDN." #module, RTE_LOG_INFO); \
} \
struct AllowTrailingSemicolon_

◆ N_LOGD

#define N_LOGD (   ...)    N_LOG(INFO, __VA_ARGS__)

◆ N_LOGE

#define N_LOGE (   ...)    N_LOG(ERR, __VA_ARGS__)

◆ N_LOGI

#define N_LOGI (   ...)    N_LOG(NOTICE, __VA_ARGS__)

◆ N_LOGV

#define N_LOGV (   ...)    N_LOG(DEBUG, __VA_ARGS__)

◆ N_LOGW

#define N_LOGW (   ...)    N_LOG(WARNING, __VA_ARGS__)

◆ RTE_LOG_DP_LEVEL

#define RTE_LOG_DP_LEVEL   RTE_LOG_DEBUG

Typedef Documentation

◆ DebugString

typedef struct DebugString DebugString

Function Documentation

◆ DebugString_Get()

DebugString* DebugString_Get ( size_t  capacity)

Obtain a buffer for populating a debug string.

Parameters
capacitybuffer capacity; panics on oversized request.
Returns
pointer to a per-lcore static buffer that will be overwritten on subsequent calls

◆ Logger_Dpdk_Init()

int Logger_Dpdk_Init ( FILE *  output)

◆ Logger_HexDump()

void Logger_HexDump ( const uint8_t *  b,
size_t  count 
)

Print buffer in hexadecimal to stderr.

This is only used during debugging, and should not appear in committed code.

◆ Logger_Spdk()

void Logger_Spdk ( int  level,
const char *restrict  file,
const int  line,
const char *restrict  func,
const char *restrict  format,
va_list  args 
)