EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
em_error.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <odp_api.h>
#include <event_machine.h>
#include "em_mem.h"
Include dependency graph for em_error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define INTERNAL_ERROR(error, escope, fmt, ...)
 
#define RETURN_ERROR_IF(cond, error, escope, fmt, ...)
 
#define EM_LOG(level, fmt, ...)
 
#define EM_VLOG(level, fmt, args)
 
#define EM_PRINT(fmt, ...)   EM_LOG(EM_LOG_PRINT, fmt, ## __VA_ARGS__)
 
#define EM_DBG(em_dbg_flag, fmt, ...)
 
#define DBG_PRINT(fmt, ...)    EM_DBG(EM_DEBUG_PRINT_BASE, fmt, ## __VA_ARGS__)
 

Functions

const char * err_status_str (em_status_t status)
 
const char * escope_api_str (em_escope_t escope)
 
const char * escope_internal_str (em_escope_t escope)
 
const char * escope_addon_api_str (em_escope_t escope)
 
size_t format_errmsg (em_status_t error, em_escope_t escope, const char *eo_str, va_list args, bool early_mode, char err_msg[], size_t errmsg_sz)
 
em_status_t internal_error (em_status_t error, em_escope_t escope,...)
 
em_status_t early_log_init (em_log_func_t user_log_fn, em_vlog_func_t user_vlog_fn)
 
void log_init (void)
 
void error_init (void)
 
em_status_t default_error_handler (em_eo_t eo, em_status_t error, em_escope_t escope, va_list args)
 
em_status_t select_error_handler (em_status_t error, em_escope_t escope, va_list args_list)
 
uint64_t load_global_err_cnt (void)
 
int default_log (em_log_level_t level, const char *fmt,...)
 
int vdefault_log (em_log_level_t level, const char *fmt, va_list args)
 

Detailed Description

Event Machine Error Handler functions

Definition in file em_error.h.

Macro Definition Documentation

◆ DBG_PRINT

#define DBG_PRINT (   fmt,
  ... 
)     EM_DBG(EM_DEBUG_PRINT_BASE, fmt, ## __VA_ARGS__)

Definition at line 105 of file em_error.h.

◆ EM_DBG

#define EM_DBG (   em_dbg_flag,
  fmt,
  ... 
)
Value:
do { \
if (em_dbg_flag) \
EM_LOG(EM_LOG_DBG, fmt, ##__VA_ARGS__); \
} while (0)

Definition at line 96 of file em_error.h.

◆ EM_LOG

#define EM_LOG (   level,
  fmt,
  ... 
)
Value:
do { \
if (log_fn) \
log_fn((level), fmt, ## __VA_ARGS__); \
else \
em_shm->log_fn((level), fmt, ## __VA_ARGS__); \
} while (0)
ENV_LOCAL em_locm_t em_locm
int(* em_log_func_t)(em_log_level_t level, const char *fmt,...) __attribute__((format(printf
em_log_func_t log_fn
Definition em_mem.h:280

Definition at line 73 of file em_error.h.

◆ EM_PRINT

#define EM_PRINT (   fmt,
  ... 
)    EM_LOG(EM_LOG_PRINT, fmt, ## __VA_ARGS__)

Definition at line 91 of file em_error.h.

◆ EM_VLOG

#define EM_VLOG (   level,
  fmt,
  args 
)
Value:
do { \
if (vlog_fn) \
vlog_fn((level), fmt, (args)); \
else \
em_shm->vlog_fn((level), fmt, (args)); \
} while (0)
int(*) typedef int(* em_vlog_func_t)(em_log_level_t level, const char *fmt, va_list args)
em_vlog_func_t vlog_fn
Definition em_mem.h:283

Definition at line 82 of file em_error.h.

◆ INTERNAL_ERROR

#define INTERNAL_ERROR (   error,
  escope,
  fmt,
  ... 
)
Value:
internal_error((error), (escope), __FILE__, __func__, \
__LINE__, fmt, ## __VA_ARGS__)
em_status_t internal_error(em_status_t error, em_escope_t escope,...)
Definition em_error.c:797

Internal error reporting macro

Definition at line 58 of file em_error.h.

◆ RETURN_ERROR_IF

#define RETURN_ERROR_IF (   cond,
  error,
  escope,
  fmt,
  ... 
)
Value:
do { \
if (unlikely((cond))) { \
return INTERNAL_ERROR((error), (escope), \
fmt, ## __VA_ARGS__); \
} \
} while (0)
#define INTERNAL_ERROR(error, escope, fmt,...)
Definition em_error.h:58

Internal macro for return on error

Definition at line 65 of file em_error.h.

Function Documentation

◆ default_error_handler()

em_status_t default_error_handler ( em_eo_t  eo,
em_status_t  error,
em_escope_t  escope,
va_list  args 
)

Default EM Error Handler

The default error handler is called upon error if the application(s) have not registered their own global and/or EO-specific error handlers

Parameters
eoEO reporting the error (if applicable)
errorThe error code (reason), see em_status_e
escopeThe error scope from within the error was reported, also tells whether the error was EM internal or application specific
argsva_list of args
Returns
The function may not return depending on implementation / error code / error scope. If it returns, the return value is the original (or modified) error code from the caller.

Definition at line 673 of file em_error.c.

◆ default_log()

int default_log ( em_log_level_t  level,
const char *  fmt,
  ... 
)

Definition at line 595 of file em_error.c.

◆ early_log_init()

em_status_t early_log_init ( em_log_func_t  user_log_fn,
em_vlog_func_t  user_vlog_fn 
)

Definition at line 831 of file em_error.c.

◆ err_status_str()

const char * err_status_str ( em_status_t  status)

Definition at line 427 of file em_error.c.

◆ error_init()

void error_init ( void  )

Initialize the EM Error Handling

Definition at line 819 of file em_error.c.

◆ escope_addon_api_str()

const char * escope_addon_api_str ( em_escope_t  escope)

Definition at line 460 of file em_error.c.

◆ escope_api_str()

const char * escope_api_str ( em_escope_t  escope)

Definition at line 436 of file em_error.c.

◆ escope_internal_str()

const char * escope_internal_str ( em_escope_t  escope)

Definition at line 448 of file em_error.c.

◆ format_errmsg()

size_t format_errmsg ( em_status_t  error,
em_escope_t  escope,
const char *  eo_str,
va_list  args,
bool  early_mode,
char  err_msg[],
size_t  errmsg_sz 
)

Definition at line 478 of file em_error.c.

◆ internal_error()

em_status_t internal_error ( em_status_t  error,
em_escope_t  escope,
  ... 
)

EM internal error Don't call directly, should always be used from within the error-macros

Called ONLY from INTERNAL_ERROR macro - do not use for anything else! internal_error((error), (escope), FILE, func, LINE, (user_fmt), ## VA_ARGS)

Definition at line 797 of file em_error.c.

◆ load_global_err_cnt()

uint64_t load_global_err_cnt ( void  )

Definition at line 568 of file em_error.c.

◆ log_init()

void log_init ( void  )

Definition at line 849 of file em_error.c.

◆ select_error_handler()

em_status_t select_error_handler ( em_status_t  error,
em_escope_t  escope,
va_list  args_list 
)

Select and call an error handler.

Parameters
errorError code
escopeError scope. Identifies the scope for interpreting the error code and variable arguments.
args_listVariable number and type of arguments
Returns
Returns the 'error' argument given as input if the called error handler has not changed this value.

Definition at line 732 of file em_error.c.

◆ vdefault_log()

int vdefault_log ( em_log_level_t  level,
const char *  fmt,
va_list  args 
)

Definition at line 574 of file em_error.c.