Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openairinterface5G
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patricio Latini
openairinterface5G
Commits
bc6d1ad4
Commit
bc6d1ad4
authored
1 year ago
by
Thomas Laurent
Browse files
Options
Downloads
Patches
Plain Diff
reduce the hot memory for LOG_x decision from 1.2MB to less than one mem page (4KB)
parent
d1002cc7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/utils/LOG/log.c
+13
-11
13 additions, 11 deletions
common/utils/LOG/log.c
common/utils/LOG/log.h
+8
-7
8 additions, 7 deletions
common/utils/LOG/log.h
with
21 additions
and
18 deletions
common/utils/LOG/log.c
+
13
−
11
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
;
...
...
This diff is collapsed.
Click to expand it.
common/utils/LOG/log.h
+
8
−
7
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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment