Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Black
OpenXG-RAN
Commits
4fea20e7
Commit
4fea20e7
authored
Nov 14, 2017
by
David Price
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get logging working - merge changes from develop branch
parent
cc02d6c1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
5 deletions
+64
-5
openair2/UTIL/LOG/log.c
openair2/UTIL/LOG/log.c
+64
-5
No files found.
openair2/UTIL/LOG/log.c
View file @
4fea20e7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#define COMPONENT_LOG
#define COMPONENT_LOG
#define COMPONENT_LOG_IF
#define COMPONENT_LOG_IF
#include <ctype.h>
#include "log.h"
#include "log.h"
#include "vcd_signal_dumper.h"
#include "vcd_signal_dumper.h"
#include "assertions.h"
#include "assertions.h"
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
# define FIFO_PRINTF_NO 62
# define FIFO_PRINTF_NO 62
# define FIFO_PRINTF_SIZE 65536
# define FIFO_PRINTF_SIZE 65536
#endif
#endif
#include "common/config/config_userapi.h"
// main log variables
// main log variables
log_t
*
g_log
;
log_t
*
g_log
;
...
@@ -103,6 +103,65 @@ static char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG
...
@@ -103,6 +103,65 @@ static char *log_level_highlight_end[] = {LOG_RESET, LOG_RESET, LOG_RESET, LOG
static
log_instance_type_t
log_instance_type
;
static
log_instance_type_t
log_instance_type
;
#endif
#endif
/* get log parameters from configuration file */
void
log_getconfig
(
log_t
*
g_log
)
{
char
*
gloglevel
=
NULL
;
char
*
glogverbo
=
NULL
;
int
level
,
verbosity
;
paramdef_t
logparams_defaults
[]
=
LOG_GLOBALPARAMS_DESC
;
paramdef_t
logparams_level
[
MAX_LOG_COMPONENTS
];
paramdef_t
logparams_verbosity
[
MAX_LOG_COMPONENTS
];
paramdef_t
logparams_logfile
[
MAX_LOG_COMPONENTS
];
int
ret
=
config_get
(
logparams_defaults
,
sizeof
(
logparams_defaults
)
/
sizeof
(
paramdef_t
),
CONFIG_STRING_LOG_PREFIX
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"[LOG] init aborted, configuration couldn't be performed"
);
return
;
}
memset
(
logparams_level
,
0
,
sizeof
(
paramdef_t
)
*
MAX_LOG_COMPONENTS
);
memset
(
logparams_verbosity
,
0
,
sizeof
(
paramdef_t
)
*
MAX_LOG_COMPONENTS
);
memset
(
logparams_logfile
,
0
,
sizeof
(
paramdef_t
)
*
MAX_LOG_COMPONENTS
);
for
(
int
i
=
MIN_LOG_COMPONENTS
;
i
<
MAX_LOG_COMPONENTS
;
i
++
)
{
if
(
g_log
->
log_component
[
i
].
name
==
NULL
)
{
g_log
->
log_component
[
i
].
name
=
malloc
(
16
);
sprintf
((
char
*
)
g_log
->
log_component
[
i
].
name
,
"comp%i?"
,
i
);
logparams_logfile
[
i
].
paramflags
=
PARAMFLAG_DONOTREAD
;
logparams_level
[
i
].
paramflags
=
PARAMFLAG_DONOTREAD
;
logparams_verbosity
[
i
].
paramflags
=
PARAMFLAG_DONOTREAD
;
}
sprintf
(
logparams_level
[
i
].
optname
,
LOG_CONFIG_LEVEL_FORMAT
,
g_log
->
log_component
[
i
].
name
);
sprintf
(
logparams_verbosity
[
i
].
optname
,
LOG_CONFIG_VERBOSITY_FORMAT
,
g_log
->
log_component
[
i
].
name
);
sprintf
(
logparams_logfile
[
i
].
optname
,
LOG_CONFIG_LOGFILE_FORMAT
,
g_log
->
log_component
[
i
].
name
);
/* workaround: all log options in existing configuration files use lower case component names
where component names include uppercase char in log.h.... */
for
(
int
j
=
0
;
j
<
strlen
(
logparams_level
[
i
].
optname
);
j
++
)
logparams_level
[
i
].
optname
[
j
]
=
tolower
(
logparams_level
[
i
].
optname
[
j
]);
for
(
int
j
=
0
;
j
<
strlen
(
logparams_level
[
i
].
optname
);
j
++
)
logparams_verbosity
[
i
].
optname
[
j
]
=
tolower
(
logparams_verbosity
[
i
].
optname
[
j
]);
for
(
int
j
=
0
;
j
<
strlen
(
logparams_level
[
i
].
optname
);
j
++
)
logparams_logfile
[
i
].
optname
[
j
]
=
tolower
(
logparams_logfile
[
i
].
optname
[
j
]);
/* */
logparams_level
[
i
].
defstrval
=
gloglevel
;
logparams_verbosity
[
i
].
defstrval
=
glogverbo
;
logparams_level
[
i
].
type
=
TYPE_STRING
;
logparams_verbosity
[
i
].
type
=
TYPE_STRING
;
logparams_logfile
[
i
].
type
=
TYPE_UINT
;
logparams_logfile
[
i
].
paramflags
=
logparams_logfile
[
i
].
paramflags
|
PARAMFLAG_BOOL
;
}
config_get
(
logparams_level
,
MAX_LOG_COMPONENTS
,
CONFIG_STRING_LOG_PREFIX
);
config_get
(
logparams_verbosity
,
MAX_LOG_COMPONENTS
,
CONFIG_STRING_LOG_PREFIX
);
config_get
(
logparams_logfile
,
MAX_LOG_COMPONENTS
,
CONFIG_STRING_LOG_PREFIX
);
for
(
int
i
=
MIN_LOG_COMPONENTS
;
i
<
MAX_LOG_COMPONENTS
;
i
++
)
{
verbosity
=
map_str_to_int
(
log_verbosity_names
,
*
(
logparams_verbosity
[
i
].
strptr
));
level
=
map_str_to_int
(
log_level_names
,
*
(
logparams_level
[
i
].
strptr
));
set_comp_log
(
i
,
level
,
verbosity
,
1
);
set_component_filelog
(
*
(
logparams_logfile
[
i
].
uptr
));
}
}
int
logInit
(
void
)
int
logInit
(
void
)
{
{
#ifdef USER_MODE
#ifdef USER_MODE
...
@@ -441,7 +500,7 @@ int logInit (void)
...
@@ -441,7 +500,7 @@ int logInit (void)
openlog
(
g_log
->
log_component
[
EMU
].
name
,
LOG_PID
,
g_log
->
config
.
facility
);
openlog
(
g_log
->
log_component
[
EMU
].
name
,
LOG_PID
,
g_log
->
config
.
facility
);
#endif // ! defined(CN_BUILD)
#endif // ! defined(CN_BUILD)
}
}
log_getconfig
(
g_log
);
if
(
g_log
->
filelog
)
{
if
(
g_log
->
filelog
)
{
gfd
=
open
(
g_log
->
filelog_name
,
O_WRONLY
|
O_CREAT
,
0666
);
gfd
=
open
(
g_log
->
filelog_name
,
O_WRONLY
|
O_CREAT
,
0666
);
}
}
...
@@ -1368,8 +1427,8 @@ int set_comp_log(int component, int level, int verbosity, int interval)
...
@@ -1368,8 +1427,8 @@ int set_comp_log(int component, int level, int verbosity, int interval)
void
set_glog
(
int
level
,
int
verbosity
)
void
set_glog
(
int
level
,
int
verbosity
)
{
{
g_log
->
level
=
level
;
if
(
g_log
->
level
>=
0
)
g_log
->
level
=
level
;
g_log
->
flag
=
verbosity
;
if
(
g_log
->
flag
>=
0
)
g_log
->
flag
=
verbosity
;
}
}
void
set_glog_syslog
(
int
enable
)
void
set_glog_syslog
(
int
enable
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment