Program Listing for File log4cl.h
↰ Return to documentation for file (rcsw/er/plugin/log4cl.h
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "rcsw/rcsw.h"
#include "rcsw/ds/llist.h"
/*******************************************************************************
* RCSW ER Plugin Definitions
******************************************************************************/
/* \cond INTERNAL */
#define RCSW_ER_PLUGIN_PRINTF printf
#define RCSW_ER_PLUGIN_MODNAME_COMPONENT_SEPARATOR "."
#define RCSW_ER_PLUGIN_INIT(...) log4cl_init(__VA_ARGS__)
#define RCSW_ER_PLUGIN_DEINIT(...) log4cl_shutdown(__VA_ARGS__)
#define RCSW_ER_PLUGIN_REPORT(LVL, HANDLE, ID, NAME, MSG, ...) \
{ \
RCSW_ER_PLUGIN_PRINTF(NAME " [" RCSW_XSTR(LVL) "] " MSG, \
## __VA_ARGS__); \
}
#define RCSW_ER_PLUGIN_INSMOD(ID, NAME) log4cl_insmod((ID), (NAME))
#define RCSW_ER_PLUGIN_HANDLE(ID, NAME) log4cl_mod_query(ID)
#define RCSW_ER_PLUGIN_LVL_CHECK(HANDLE, LVL) \
log4cl_mod_emit(HANDLE, RCSW_JOIN(RCSW_ERL_, LVL))
#define RCSW_LOG4CL_NAMELEN 32
/*******************************************************************************
* Module codes
******************************************************************************/
#define RCSW_LOG4CL_MODULES \
ekLOG4CL_SELF, \
ekLOG4CL_DS_BSTREE, \
ekLOG4CL_DS_DARRAY, \
ekLOG4CL_DS_LLIST, \
ekLOG4CL_DS_HASHMAP, \
ekLOG4CL_DS_RBUFFER, \
ekLOG4CL_MT_PCQUEUE, \
ekLOG4CL_MT_MPOOL, \
ekLOG4CL_UTILS, \
ekLOG4CL_SWBUS, \
ekLOG4CL_STDIO, \
ekLOG4CL_GRIND, \
ekLOG4CL_DS_CORE, \
ekLOG4CL_DS_BINHEAP, \
ekLOG4CL_DS_CSMATRIX, \
ekLOG4CL_COMMON, \
ekLOG4CL_DS_FIFO, \
ekLOG4CL_DS_MULTIFIFO, \
ekLOG4CL_DS_RAWFIFO, \
ekLOG4CL_ALGORITHM, \
ekLOG4CL_DS_RBTREE, \
ekLOG4CL_TESTING, \
ekLOG4CL_DS_INT_TREE, \
ekLOG4CL_DS_OSTREE, \
ekLOG4CL_DS_ADJ_MATRIX, \
ekLOG4CL_DS_MATRIX, \
ekLOG4CL_DS_DYN_MATRIX, \
ekLOG4CL_MT_RDWRLOCK, \
ekLOG4CL_MT_RADIX, \
ekLOG4CL_MULTIPROCESS, \
ekLOG4CL_CTRL_PID, \
ekLOG4CL_EXTERNAL
enum log4cl_module_codes {RCSW_XTABLE_SEQ_ENUM(RCSW_LOG4CL_MODULES)};
/* \endcond */
/*******************************************************************************
* Structure Definitions
******************************************************************************/
struct RCSW_ATTR(packed, aligned (sizeof(dptr_t))) log4cl_module {
int64_t id;
uint8_t lvl;
char name[RCSW_LOG4CL_NAMELEN];
};
struct log4cl_plugin {
struct llist *modules;
uint8_t default_lvl;
bool_t initialized;
};
/*******************************************************************************
* Global Variables
******************************************************************************/
BEGIN_C_DECLS
/*******************************************************************************
* API Functions
******************************************************************************/
RCSW_API struct log4cl_module* log4cl_mod_query(uint64_t id) RCSW_CONST;
RCSW_API bool_t log4cl_mod_emit(const struct log4cl_module* module,
uint8_t lvl) RCSW_PURE;
RCSW_API status_t log4cl_init(void);
RCSW_API void log4cl_shutdown(void);
RCSW_API status_t log4cl_insmod(int64_t id, const char *name);
RCSW_API status_t log4cl_rmmod(int64_t id);
RCSW_API status_t log4cl_rmmod2(const char *name);
RCSW_API status_t log4cl_mod_lvl_set(int64_t id, uint8_t lvl);
RCSW_API void log4cl_default_lvl_set(uint8_t lvl);
RCSW_API int64_t log4cl_mod_id_get(const char* name) RCSW_PURE;
END_C_DECLS