Commit 4cd5d80d authored by wujing's avatar wujing

add log-mem function to collect log

parent d5d1c195
This diff is collapsed.
...@@ -118,6 +118,8 @@ extern "C" { ...@@ -118,6 +118,8 @@ extern "C" {
#define FLAG_NOCOLOR 0x0001 /*!< \brief use colors in log messages, depending on level */ #define FLAG_NOCOLOR 0x0001 /*!< \brief use colors in log messages, depending on level */
#define FLAG_THREAD 0x0008 /*!< \brief display thread name in log messages */ #define FLAG_THREAD 0x0008 /*!< \brief display thread name in log messages */
#define FLAG_LEVEL 0x0010 /*!< \brief display log level in log messages */ #define FLAG_LEVEL 0x0010 /*!< \brief display log level in log messages */
#define FLAG_FUNCT 0x0020
#define FLAG_FILE_LINE 0x0040
#define FLAG_TIME 0x0100 #define FLAG_TIME 0x0100
#define FLAG_INITIALIZED 0x8000 #define FLAG_INITIALIZED 0x8000
...@@ -307,6 +309,19 @@ int is_newline( char *str, int size); ...@@ -307,6 +309,19 @@ int is_newline( char *str, int size);
int register_log_component(char *name, char *fext, int compidx); int register_log_component(char *name, char *fext, int compidx);
#define LOG_MEM_SIZE 100*1024*1024
#define LOG_MEM_FILE "./logmem.log"
void flush_mem_to_file(void);
void log_output_memory(const char *file, const char *func, int line, int comp, int level, const char* format,va_list args);
int logInit_log_mem(void);
void close_log_mem(void);
typedef struct {
char* buf_p;
int buf_index;
int enable_flag;
} log_mem_cnt_t;
/* @}*/ /* @}*/
/*!\fn int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, char format); /*!\fn int32_t write_file_matlab(const char *fname, const char *vname, void *data, int length, int dec, char format);
......
...@@ -27,4 +27,6 @@ extern log_t *g_log; ...@@ -27,4 +27,6 @@ extern log_t *g_log;
extern mapping log_level_names[]; extern mapping log_level_names[];
extern mapping log_options[]; extern mapping log_options[];
extern mapping log_maskmap[]; extern mapping log_maskmap[];
extern int log_mem_flag;
extern char * log_mem_filename;
extern char logmem_filename[1024];
...@@ -60,6 +60,7 @@ void get_common_options(void) { ...@@ -60,6 +60,7 @@ void get_common_options(void) {
uint32_t nonbiot; uint32_t nonbiot;
uint32_t rfsim; uint32_t rfsim;
uint32_t basicsim; uint32_t basicsim;
char *logmem_filename = NULL;
paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ; paramdef_t cmdline_params[] =CMDLINE_PARAMS_DESC ;
paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ; paramdef_t cmdline_logparams[] =CMDLINE_LOGPARAMS_DESC ;
checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC; checkedparam_t cmdline_log_CheckParams[] = CMDLINE_LOGPARAMS_CHECK_DESC;
...@@ -80,6 +81,13 @@ void get_common_options(void) { ...@@ -80,6 +81,13 @@ void get_common_options(void) {
load_module_shlib("telnetsrv",NULL,0,NULL); load_module_shlib("telnetsrv",NULL,0,NULL);
} }
if (logmem_filename != NULL && strlen(logmem_filename) > 0) {
log_mem_filename = &logmem_filename[0];
log_mem_flag = 1;
printf("Enabling OPT for log save at memory %s\n",log_mem_filename);
logInit_log_mem();
}
if (noS1) { if (noS1) {
set_softmodem_optmask(SOFTMODEM_NOS1_BIT); set_softmodem_optmask(SOFTMODEM_NOS1_BIT);
} }
......
...@@ -279,7 +279,7 @@ void exit_function(const char *file, const char *function, const int line, const ...@@ -279,7 +279,7 @@ void exit_function(const char *file, const char *function, const int line, const
if (s != NULL) { if (s != NULL) {
printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s); printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, s);
} }
close_log_mem();
oai_exit = 1; oai_exit = 1;
if (RC.ru == NULL) if (RC.ru == NULL)
......
...@@ -222,6 +222,7 @@ ...@@ -222,6 +222,7 @@
{"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \ {"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
{"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \ {"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \
{"msc", CONFIG_HLP_MSC, PARAMFLAG_BOOL, uptr:&START_MSC, defintval:0, TYPE_UINT, 0}, \ {"msc", CONFIG_HLP_MSC, PARAMFLAG_BOOL, uptr:&START_MSC, defintval:0, TYPE_UINT, 0}, \
{"log-mem", NULL, 0, strptr:(char **)&logmem_filename, defstrval:NULL, TYPE_STRING, 0}, \
} }
#define CMDLINE_ONLINELOG_IDX 0 #define CMDLINE_ONLINELOG_IDX 0
#define CMDLINE_GLOGLEVEL_IDX 1 #define CMDLINE_GLOGLEVEL_IDX 1
...@@ -233,6 +234,7 @@ ...@@ -233,6 +234,7 @@
{ .s2= { config_check_intrange, {0,4}}}, \ { .s2= { config_check_intrange, {0,4}}}, \
{ .s5= {NULL }} , \ { .s5= {NULL }} , \
{ .s5= {NULL }} , \ { .s5= {NULL }} , \
{ .s5= {NULL }} , \
} }
/***************************************************************************************************************************************/ /***************************************************************************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment