remove global visibility of log variables, remove circular .h dependancy
This commit is contained in:
+22
-30
@@ -46,7 +46,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdatomic.h>
|
||||
#include "common/utils/LOG/log_extern.h"
|
||||
#include "common/utils/LOG/log.h"
|
||||
|
||||
// main log variables
|
||||
|
||||
@@ -58,18 +58,16 @@ void read_cpu_hardware (void) __attribute__ ((constructor));
|
||||
void read_cpu_hardware (void) {}
|
||||
#endif
|
||||
|
||||
log_mem_cnt_t log_mem_d[2];
|
||||
int log_mem_flag = 0;
|
||||
static log_mem_cnt_t log_mem_d[2];
|
||||
static int log_mem_flag = 0;
|
||||
volatile int log_mem_side=0;
|
||||
pthread_mutex_t log_mem_lock;
|
||||
pthread_cond_t log_mem_notify;
|
||||
pthread_t log_mem_thread;
|
||||
int log_mem_file_cnt=0;
|
||||
static pthread_mutex_t log_mem_lock;
|
||||
static pthread_cond_t log_mem_notify;
|
||||
static pthread_t log_mem_thread;
|
||||
static int log_mem_file_cnt=0;
|
||||
volatile int log_mem_write_flag=0;
|
||||
volatile int log_mem_write_side=0;
|
||||
char __log_mem_filename[1024]={0};
|
||||
char * log_mem_filename = &__log_mem_filename[0];
|
||||
char logmem_filename[1024] = {0};
|
||||
static char * log_mem_filename;
|
||||
|
||||
const mapping log_level_names[] = {{"error", OAILOG_ERR},
|
||||
{"warn", OAILOG_WARNING},
|
||||
@@ -935,28 +933,22 @@ static void log_output_memory(log_component_t *c, const char *file, const char *
|
||||
}
|
||||
}
|
||||
|
||||
int logInit_log_mem (void)
|
||||
int logInit_log_mem (char * filename)
|
||||
{
|
||||
if (log_mem_flag == 1) {
|
||||
log_mem_d[0].buf_p = malloc(LOG_MEM_SIZE);
|
||||
log_mem_d[0].buf_index = 0;
|
||||
log_mem_d[0].enable_flag = 1;
|
||||
log_mem_d[1].buf_p = malloc(LOG_MEM_SIZE);
|
||||
log_mem_d[1].buf_index = 0;
|
||||
log_mem_d[1].enable_flag = 1;
|
||||
log_mem_side = 0;
|
||||
if ((pthread_mutex_init(&log_mem_lock, NULL) != 0) || (pthread_cond_init(&log_mem_notify, NULL) != 0)) {
|
||||
log_mem_d[1].enable_flag=0;
|
||||
return -1;
|
||||
}
|
||||
pthread_create(&log_mem_thread, NULL, (void *(*)(void *))flush_mem_to_file, (void *)NULL);
|
||||
} else {
|
||||
log_mem_d[0].buf_p = NULL;
|
||||
log_mem_d[1].buf_p = NULL;
|
||||
log_mem_d[0].enable_flag = 0;
|
||||
log_mem_d[1].enable_flag = 0;
|
||||
log_mem_flag = 1;
|
||||
log_mem_filename = filename; // in present code, the parameter is safe permanent pointer
|
||||
log_mem_d[0].buf_p = malloc(LOG_MEM_SIZE);
|
||||
log_mem_d[0].buf_index = 0;
|
||||
log_mem_d[0].enable_flag = 1;
|
||||
log_mem_d[1].buf_p = malloc(LOG_MEM_SIZE);
|
||||
log_mem_d[1].buf_index = 0;
|
||||
log_mem_d[1].enable_flag = 1;
|
||||
log_mem_side = 0;
|
||||
if ((pthread_mutex_init(&log_mem_lock, NULL) != 0) || (pthread_cond_init(&log_mem_notify, NULL) != 0)) {
|
||||
log_mem_d[1].enable_flag=0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_create(&log_mem_thread, NULL, (void *(*)(void *))flush_mem_to_file, (void *)NULL);
|
||||
printf("log init done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -272,8 +272,7 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/*--- INCLUDES ---------------------------------------------------------------*/
|
||||
# include "log_if.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int logInit (void);
|
||||
void logTerm (void);
|
||||
@@ -299,7 +298,7 @@ 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);
|
||||
int logInit_log_mem(void);
|
||||
int logInit_log_mem(char*);
|
||||
void close_log_mem(void);
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
|
||||
extern log_t *g_log;
|
||||
|
||||
extern const mapping log_level_names[];
|
||||
extern const mapping log_options[];
|
||||
extern const mapping log_maskmap[];
|
||||
extern int log_mem_flag;
|
||||
extern char * log_mem_filename;
|
||||
extern char logmem_filename[1024];
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.openairinterface.org/?page_id=698
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
/*! \file log_if.h
|
||||
* \brief log interface
|
||||
* \author Navid Nikaein
|
||||
* \date 2009 - 2014
|
||||
* \version 0.3
|
||||
* \warning This component can be runned only in user-space
|
||||
* @ingroup routing
|
||||
*/
|
||||
|
||||
// LTS: kept this file for compatibility
|
||||
// this file was probably a trial to separate internal functions and external ones
|
||||
// but it has never been finished, most source code include directly log.h (not log_if.h)
|
||||
#include "log.h"
|
||||
Reference in New Issue
Block a user