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
spbro
OpenXG-RAN
Commits
bc6d1ad4
Commit
bc6d1ad4
authored
Mar 01, 2024
by
Laurent THOMAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce the hot memory for LOG_x decision from 1.2MB to less than one mem page (4KB)
parent
d1002cc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
common/utils/LOG/log.c
common/utils/LOG/log.c
+13
-11
common/utils/LOG/log.h
common/utils/LOG/log.h
+8
-7
No files found.
common/utils/LOG/log.c
View file @
bc6d1ad4
...
...
@@ -416,8 +416,8 @@ int register_log_component(char *name,
g_log
->
log_component
[
computed_compidx
].
name
=
strdup
(
name
);
g_log
->
log_component
[
computed_compidx
].
stream
=
stdout
;
g_log
->
log_component
[
computed_compidx
].
filelog
=
0
;
g_log
->
log_
component
[
computed_compidx
].
filelog_name
=
malloc
(
strlen
(
name
)
+
16
);
/* /tmp/<name>.%s */
sprintf
(
g_log
->
log_
component
[
computed_compidx
].
filelog_name
,
"/tmp/%s.%s"
,
name
,
fext
);
g_log
->
log_
rarely_used
[
computed_compidx
].
filelog_name
=
malloc
(
strlen
(
name
)
+
16
);
/* /tmp/<name>.%s */
sprintf
(
g_log
->
log_
rarely_used
[
computed_compidx
].
filelog_name
,
"/tmp/%s.%s"
,
name
,
fext
);
}
else
{
fprintf
(
stderr
,
"{LOG} %s %d Couldn't register component %s
\n
"
,
__FILE__
,
__LINE__
,
name
);
}
...
...
@@ -427,11 +427,13 @@ int register_log_component(char *name,
static
void
unregister_all_log_components
(
void
)
{
log_component_t
*
lc
=
&
g_log
->
log_component
[
0
];
log_component_t
*
lc
=
g_log
->
log_component
;
log_component_back_t
*
lb
=
g_log
->
log_rarely_used
;
while
(
lc
->
name
)
{
free
((
char
*
)
lc
->
name
);
// defined as const, but assigned through strdup()
free
(
l
c
->
filelog_name
);
free
(
l
b
->
filelog_name
);
lc
++
;
lb
++
;
}
}
...
...
@@ -545,7 +547,7 @@ static inline int log_header(log_component_t *c,
int
line
,
int
level
)
{
int
flag
=
g_log
->
flag
|
c
->
flag
;
int
flag
=
g_log
->
flag
;
//
| c->flag;
char
threadname
[
64
];
if
(
flag
&
FLAG_THREAD
)
{
...
...
@@ -635,8 +637,8 @@ void log_dump(int component,
va_list
args
;
char
*
wbuf
;
log_component_t
*
c
=
&
g_log
->
log_component
[
component
];
int
flag
=
g_log
->
flag
|
c
->
flag
;
int
flag
=
g_log
->
flag
;
//
| c->flag;
switch
(
datatype
)
{
case
LOG_DUMP_DOUBLE
:
wbuf
=
malloc
((
buffsize
*
10
)
+
64
+
MAX_LOG_TOTAL
);
...
...
@@ -685,7 +687,7 @@ int set_log(int component,
OAILOG_ERR
);
if
(
g_log
->
log_component
[
component
].
level
!=
OAILOG_DISABLE
)
g_log
->
log_
component
[
component
].
savedlevel
=
g_log
->
log_component
[
component
].
level
;
g_log
->
log_
rarely_used
[
component
].
savedlevel
=
g_log
->
log_component
[
component
].
level
;
g_log
->
log_component
[
component
].
level
=
level
;
return
0
;
...
...
@@ -704,7 +706,7 @@ void set_glog_onlinelog(int enable)
{
for
(
int
c
=
0
;
c
<
MAX_LOG_COMPONENTS
;
c
++
)
{
if
(
enable
)
{
g_log
->
log_component
[
c
].
level
=
g_log
->
log_
component
[
c
].
savedlevel
;
g_log
->
log_component
[
c
].
level
=
g_log
->
log_
rarely_used
[
c
].
savedlevel
;
g_log
->
log_component
[
c
].
vprint
=
vfprintf
;
g_log
->
log_component
[
c
].
print
=
fprintf
;
g_log
->
log_component
[
c
].
stream
=
stdout
;
...
...
@@ -741,7 +743,7 @@ void set_glog_filelog(int enable)
void
set_component_filelog
(
int
comp
)
{
if
(
g_log
->
log_component
[
comp
].
stream
==
NULL
||
g_log
->
log_component
[
comp
].
stream
==
stdout
)
{
g_log
->
log_component
[
comp
].
stream
=
fopen
(
g_log
->
log_
component
[
comp
].
filelog_name
,
"w"
);
g_log
->
log_component
[
comp
].
stream
=
fopen
(
g_log
->
log_
rarely_used
[
comp
].
filelog_name
,
"w"
);
}
g_log
->
log_component
[
comp
].
vprint
=
vfprintf
;
...
...
@@ -892,7 +894,7 @@ static void log_output_memory(log_component_t *c, const char *file, const char *
len
=
MAX_LOG_TOTAL
;
}
}
if
(
!
((
g_log
->
flag
|
c
->
flag
)
&
FLAG_NOCOLOR
)
)
{
if
(
!
((
g_log
->
flag
/*| c->flag*/
)
&
FLAG_NOCOLOR
)
)
{
int
n
=
snprintf
(
log_buffer
+
len
,
MAX_LOG_TOTAL
-
len
,
"%s"
,
log_level_highlight_end
[
level
]);
if
(
n
>
0
)
{
len
+=
n
;
...
...
common/utils/LOG/log.h
View file @
bc6d1ad4
...
...
@@ -235,23 +235,24 @@ typedef struct {
typedef
int
(
*
log_vprint_func_t
)(
FILE
*
stream
,
const
char
*
format
,
va_list
ap
);
typedef
int
(
*
log_print_func_t
)(
FILE
*
stream
,
const
char
*
format
,
...
);
typedef
struct
{
int
savedlevel
;
char
*
filelog_name
;
}
log_component_back_t
;
typedef
struct
{
const
char
*
name
;
int
level
;
int
savedlevel
;
int
flag
;
int
filelog
;
char
*
filelog_name
;
int
filelog
;
FILE
*
stream
;
log_vprint_func_t
vprint
;
log_print_func_t
print
;
/* SR: make the log buffer component relative */
// char log_buffer[MAX_LOG_TOTAL];
log_print_func_t
print
;
}
log_component_t
;
typedef
struct
{
log_component_t
log_component
[
MAX_LOG_COMPONENTS
];
log_component_back_t
log_rarely_used
[
MAX_LOG_COMPONENTS
];
char
level2string
[
NUM_LOG_LEVEL
];
int
flag
;
char
*
filelog_name
;
...
...
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