Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
F
ffworker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Video AG Infrastruktur
ffworker
Commits
3e605479
Commit
3e605479
authored
Nov 27, 2017
by
Julian Rother
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avlogbuf: Collapse repeating messages
parent
22d0d3a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
util/avlogbuf.c
util/avlogbuf.c
+23
-2
No files found.
util/avlogbuf.c
View file @
3e605479
...
...
@@ -6,6 +6,9 @@
static
char
*
logbuffer
;
static
size_t
logsize
;
static
FILE
*
logstream
;
static
pthread_mutex_t
mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
char
prevbuf
[
200
]
=
""
;
static
int
repeats
=
0
;
void
init_avlogbuf
(
void
)
{
...
...
@@ -20,21 +23,39 @@ void avlogbuf_callback(void *class, int level, const char *fmt, va_list ap)
{
int
print_prefix
;
char
buf
[
200
];
if
(
level
>
=
AV_LOG_VERBOSE
)
if
(
level
>
AV_LOG_WARNING
)
return
;
print_prefix
=
1
;
av_log_format_line
(
class
,
level
,
fmt
,
ap
,
BL
(
buf
),
&
print_prefix
);
if
(
pthread_mutex_lock
(
&
mutex
))
return
;
if
(
!
strcmp
(
buf
,
prevbuf
))
{
repeats
++
;
pthread_mutex_unlock
(
&
mutex
);
return
;
}
if
(
repeats
)
fprintf
(
logstream
,
"Last message repeated %d times
\n
"
,
repeats
);
repeats
=
0
;
strcpy
(
prevbuf
,
buf
);
fputs
(
buf
,
logstream
);
pthread_mutex_unlock
(
&
mutex
);
}
char
*
get_avlogbuf
(
void
)
{
char
*
p
;
char
*
p
,
*
tmp
;
if
(
!
logstream
)
return
""
;
fclose
(
logstream
);
p
=
logbuffer
;
init_avlogbuf
();
fputs
(
p
,
logstream
);
if
(
repeats
)
{
tmp
=
mprintf
(
"%sLast message repeated %d times
\n
"
,
p
,
repeats
);
free
(
p
);
p
=
tmp
;
}
return
p
;
}
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