MSC logging utility as a config option
This commit is contained in:
@@ -455,13 +455,14 @@ int rt = pthread_getname_np(pthread_self(), threadname,bufsize) ;
|
||||
|
||||
int inline log_header(char *log_buffer, int buffsize, int comp, int level,const char *format) {
|
||||
char threadname[PR_SET_NAME];
|
||||
return snprintf(log_buffer, buffsize , "%s%s[%s]%c %s %s",
|
||||
return snprintf(log_buffer, buffsize , "%s%s[%s]%c %s %s%s",
|
||||
log_level_highlight_end[level],
|
||||
( (g_log->flag & FLAG_NOCOLOR)?"":log_level_highlight_start[level]),
|
||||
g_log->log_component[comp].name,
|
||||
( (g_log->flag & FLAG_LEVEL)?g_log->level2string[level]:' '),
|
||||
( (g_log->flag & FLAG_THREAD)?log_getthreadname(threadname,PR_SET_NAME+1):""),
|
||||
format);
|
||||
format,
|
||||
log_level_highlight_end[level]);
|
||||
}
|
||||
|
||||
void logRecord_mt(const char *file, const char *func, int line, int comp, int level, const char* format, ... )
|
||||
|
||||
@@ -118,7 +118,7 @@ int ret;
|
||||
return tmpstr;
|
||||
}
|
||||
|
||||
int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf)
|
||||
int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf, void *autoinit_arg)
|
||||
{
|
||||
void *lib_handle;
|
||||
initfunc_t fpi;
|
||||
@@ -155,7 +155,7 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf)
|
||||
fpi = dlsym(lib_handle,afname);
|
||||
|
||||
if (fpi != NULL ) {
|
||||
fpi();
|
||||
fpi(autoinit_arg);
|
||||
}
|
||||
|
||||
if (farray != NULL) {
|
||||
|
||||
@@ -59,7 +59,8 @@ typedef struct {
|
||||
|
||||
/* function type of functions which may be implemented by a module */
|
||||
/* 1: init function, called when loading, if found in the shared lib */
|
||||
typedef int(*initfunc_t)(void);
|
||||
typedef int(*initfunc_t)(void *);
|
||||
|
||||
/* 2: version checking function, called when loading, if it returns -1, trigger main exec abort */
|
||||
typedef int(*checkverfunc_t)(char * mainexec_version, char ** shlib_version);
|
||||
/* 3: get function array function, called when loading when a module doesn't provide */
|
||||
@@ -83,7 +84,7 @@ loader_data_t loader_data;
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------*/
|
||||
#else /* LOAD_MODULE_SHLIB_MAIN */
|
||||
extern int load_module_shlib(char *modname, loader_shlibfunc_t *farray, int numf);
|
||||
extern int load_module_shlib(char *modname, loader_shlibfunc_t *farray, int numf, void *initfunc_arg);
|
||||
extern void * get_shlibmodule_fptr(char *modname, char *fname);
|
||||
extern loader_data_t loader_data;
|
||||
#endif /* LOAD_MODULE_SHLIB_MAIN */
|
||||
|
||||
+23
-6
@@ -32,11 +32,15 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define MSC_LIBRARY
|
||||
#include "msc.h"
|
||||
|
||||
#include "liblfds611.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include "msc.h"
|
||||
|
||||
|
||||
#include "assertions.h"
|
||||
|
||||
//-------------------------------
|
||||
@@ -67,8 +71,8 @@ void *msc_task(void *args_p)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
MessageDef *received_message_p = NULL;
|
||||
const char *msg_name = NULL;
|
||||
instance_t instance = 0;
|
||||
// const char *msg_name = NULL;
|
||||
// instance_t instance = 0;
|
||||
long timer_id;
|
||||
|
||||
itti_mark_task_ready(TASK_MSC);
|
||||
@@ -88,9 +92,9 @@ void *msc_task(void *args_p)
|
||||
itti_receive_msg(TASK_MSC, &received_message_p);
|
||||
|
||||
if (received_message_p != NULL) {
|
||||
msg_name = ITTI_MSG_NAME (received_message_p);
|
||||
instance = ITTI_MSG_INSTANCE (received_message_p);
|
||||
|
||||
// msg_name = ITTI_MSG_NAME (received_message_p);
|
||||
// instance = ITTI_MSG_INSTANCE (received_message_p);
|
||||
|
||||
switch (ITTI_MSG_ID(received_message_p)) {
|
||||
|
||||
case TIMER_HAS_EXPIRED: {
|
||||
@@ -571,4 +575,17 @@ error_event:
|
||||
free(new_item_p);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// function called when oai loader loads the msc shared lib
|
||||
int msc_autoinit(msc_interface_t *msc_interface)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
msc_interface->msc_init = msc_init;
|
||||
msc_interface->msc_start_use = msc_start_use;
|
||||
msc_interface->msc_end = msc_end;
|
||||
msc_interface->msc_log_event = msc_log_event;
|
||||
msc_interface->msc_log_message = msc_log_message;
|
||||
msc_interface->msc_loaded = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+29
-18
@@ -73,7 +73,23 @@ typedef enum {
|
||||
#define MSC_AS_TIME_ARGS(CTXT_Pp) \
|
||||
(CTXT_Pp)->frame, \
|
||||
(CTXT_Pp)->subframe
|
||||
#if defined(MESSAGE_CHART_GENERATOR)
|
||||
|
||||
typedef int(*msc_init_t)(const msc_env_t, const int );
|
||||
typedef void(*msc_start_use_t)(void );
|
||||
typedef void(*msc_end_t)(void);
|
||||
typedef void(*msc_log_event_t)(const msc_proto_t,char *, ...);
|
||||
typedef void(*msc_log_message_t)(const char * const, const msc_proto_t, const msc_proto_t,
|
||||
const uint8_t* const, const unsigned int, char * , ...);
|
||||
typedef struct msc_interface {
|
||||
int msc_loaded;
|
||||
msc_init_t msc_init;
|
||||
msc_start_use_t msc_start_use;
|
||||
msc_end_t msc_end;
|
||||
msc_log_event_t msc_log_event;
|
||||
msc_log_message_t msc_log_message;
|
||||
} msc_interface_t;
|
||||
|
||||
#ifdef MSC_LIBRARY
|
||||
int msc_init(const msc_env_t envP, const int max_threadsP);
|
||||
void msc_start_use(void);
|
||||
void msc_flush_messages(void);
|
||||
@@ -88,22 +104,17 @@ void msc_log_message(
|
||||
const unsigned int num_bytes,
|
||||
char *format, ...);
|
||||
|
||||
#define MSC_INIT(arg1,arg2) msc_init(arg1,arg2)
|
||||
#define MSC_START_USE msc_start_use
|
||||
#define MSC_END msc_end
|
||||
#define MSC_LOG_EVENT(mScPaRaMs, fORMAT, aRGS...) msc_log_event(mScPaRaMs, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_RX_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...) msc_log_message("<-",rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_RX_DISCARDED_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...) msc_log_message("x-",rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_TX_MESSAGE(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...) msc_log_message("->",sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_TX_MESSAGE_FAILED(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...) msc_log_message("-x",sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#else
|
||||
#define MSC_INIT(arg1,arg2)
|
||||
#define MSC_START_USE(mScPaRaMs)
|
||||
#define MSC_END(mScPaRaMs)
|
||||
#define MSC_LOG_EVENT(mScPaRaMs, fORMAT, aRGS...)
|
||||
#define MSC_LOG_RX_MESSAGE(mScPaRaMs, fORMAT, aRGS...)
|
||||
#define MSC_LOG_RX_DISCARDED_MESSAGE(mScPaRaMs, fORMAT, aRGS...)
|
||||
#define MSC_LOG_TX_MESSAGE(mScPaRaMs, fORMAT, aRGS...)
|
||||
#define MSC_LOG_TX_MESSAGE_FAILED(mScPaRaMs, fORMAT, aRGS...)
|
||||
#endif
|
||||
|
||||
msc_interface_t msc_interface;
|
||||
#define MSC_INIT(arg1,arg2) if(msc_interface.msc_loaded) msc_interface.msc_init(arg1,arg2)
|
||||
#define MSC_START_USE if(msc_interface.msc_loaded) msc_interface.msc_start_use
|
||||
#define MSC_END if(msc_interface.msc_loaded) msc_interface.msc_end
|
||||
#define MSC_LOG_EVENT(mScPaRaMs, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_event(mScPaRaMs, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_RX_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_message("<-",rECEIVER, sENDER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_RX_DISCARDED_MESSAGE(rECEIVER, sENDER, bYTES, nUMbYTES, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_message("x-",rECEIVER, sENDER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_TX_MESSAGE(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_message("->",sENDER, rECEIVER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#define MSC_LOG_TX_MESSAGE_FAILED(sENDER, rECEIVER, bYTES, nUMbYTES, fORMAT, aRGS...) if(msc_interface.msc_loaded) msc_interface.msc_log_message("-x",sENDER, rECEIVER, (const uint8_t *)bYTES, nUMbYTES, fORMAT, ##aRGS)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user