Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemCore
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemCore
Commits
13438a93
Commit
13438a93
authored
Feb 28, 2012
by
Jean-Baptiste Queru
Committed by
android code review
Feb 28, 2012
Browse files
Options
Downloads
Plain Diff
Merge "logwrapper: reduce verbosity and fix usage"
parents
1ea9fce4
1f28b775
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
logwrapper/logwrapper.c
+11
-6
11 additions, 6 deletions
logwrapper/logwrapper.c
with
11 additions
and
6 deletions
logwrapper/logwrapper.c
+
11
−
6
View file @
13438a93
...
...
@@ -22,6 +22,7 @@
#include
<unistd.h>
#include
<errno.h>
#include
<fcntl.h>
#include
<libgen.h>
#include
"private/android_filesystem_config.h"
#include
"cutils/log.h"
...
...
@@ -34,13 +35,13 @@ void fatal(const char *msg) {
void
usage
()
{
fatal
(
"Usage: logwrapper [-
x
] BINARY [ARGS ...]
\n
"
"Usage: logwrapper [-
d
] BINARY [ARGS ...]
\n
"
"
\n
"
"Forks and executes BINARY ARGS, redirecting stdout and stderr to
\n
"
"the Android logging system. Tag is set to BINARY, priority is
\n
"
"always LOG_INFO.
\n
"
"
\n
"
"-
x
: Causes logwrapper to SIGSEGV when BINARY terminates
\n
"
"-
d
: Causes logwrapper to SIGSEGV when BINARY terminates
\n
"
" fault address is set to the status of wait()
\n
"
);
}
...
...
@@ -51,6 +52,10 @@ void parent(const char *tag, int seg_fault_on_exit, int parent_read) {
int
a
=
0
;
// start index of unprocessed data
int
b
=
0
;
// end index of unprocessed data
int
sz
;
char
*
btag
=
basename
(
tag
);
if
(
!
btag
)
btag
=
(
char
*
)
tag
;
while
((
sz
=
read
(
parent_read
,
&
buffer
[
b
],
sizeof
(
buffer
)
-
1
-
b
))
>
0
)
{
sz
+=
b
;
...
...
@@ -60,7 +65,7 @@ void parent(const char *tag, int seg_fault_on_exit, int parent_read) {
buffer
[
b
]
=
'\0'
;
}
else
if
(
buffer
[
b
]
==
'\n'
)
{
buffer
[
b
]
=
'\0'
;
ALOG
(
LOG_INFO
,
tag
,
"%s"
,
&
buffer
[
a
]);
ALOG
(
LOG_INFO
,
b
tag
,
"%s"
,
&
buffer
[
a
]);
a
=
b
+
1
;
}
}
...
...
@@ -68,7 +73,7 @@ void parent(const char *tag, int seg_fault_on_exit, int parent_read) {
if
(
a
==
0
&&
b
==
sizeof
(
buffer
)
-
1
)
{
// buffer is full, flush
buffer
[
b
]
=
'\0'
;
ALOG
(
LOG_INFO
,
tag
,
"%s"
,
&
buffer
[
a
]);
ALOG
(
LOG_INFO
,
b
tag
,
"%s"
,
&
buffer
[
a
]);
b
=
0
;
}
else
if
(
a
!=
b
)
{
// Keep left-overs
...
...
@@ -84,11 +89,11 @@ void parent(const char *tag, int seg_fault_on_exit, int parent_read) {
// Flush remaining data
if
(
a
!=
b
)
{
buffer
[
b
]
=
'\0'
;
ALOG
(
LOG_INFO
,
tag
,
"%s"
,
&
buffer
[
a
]);
ALOG
(
LOG_INFO
,
b
tag
,
"%s"
,
&
buffer
[
a
]);
}
status
=
0xAAAA
;
if
(
wait
(
&
status
)
!=
-
1
)
{
// Wait for child
if
(
WIFEXITED
(
status
))
if
(
WIFEXITED
(
status
)
&&
WEXITSTATUS
(
status
)
)
ALOG
(
LOG_INFO
,
"logwrapper"
,
"%s terminated by exit(%d)"
,
tag
,
WEXITSTATUS
(
status
));
else
if
(
WIFSIGNALED
(
status
))
...
...
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