Skip to content

Commit

Permalink
logwrapper: Add ability to log to kernel log
Browse files Browse the repository at this point in the history
Also add ability to do abbreviated logging where only the first
4K bytes and last 4K bytes of output are added to the desginated log.

Also update standalog logwrapper command to support the new options.

Change-Id: Ia49cbe58479b9f9ed077498d6852e20b21287bad
  • Loading branch information
Ken Sumrall committed Apr 15, 2013
1 parent 7425fd1 commit 96e11b5
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 46 deletions.
2 changes: 1 addition & 1 deletion logwrapper/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= logwrapper.c
LOCAL_MODULE := logwrapper
LOCAL_STATIC_LIBRARIES := liblog liblogwrap
LOCAL_STATIC_LIBRARIES := liblog liblogwrap libcutils
include $(BUILD_EXECUTABLE)
29 changes: 26 additions & 3 deletions logwrapper/include/logwrap/logwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ __BEGIN_DECLS
* SIGQUIT while logwrap is running. This may force the end-user to
* send a signal twice to signal the caller (once for the child, and
* once for the caller)
* logwrap: when true, log messages from the child
* log_target: Specify where to log the output of the child, either LOG_NONE,
* LOG_ALOG (for the Android system log) or LOG_KLOG (for the kernel
* log).
* abbreviated: If true, capture up to the first 100 lines and last 4K of
* output from the child. The abbreviated output is not dumped to
* the specified log until the child has exited.
*
* Return value:
* 0 when logwrap successfully run the child process and captured its status
Expand All @@ -52,8 +57,26 @@ __BEGIN_DECLS
* the return value of the child if it exited properly and status is NULL
*
*/
int android_fork_execvp(int argc, char* argv[], int *status, bool ignore_int_quit,
bool logwrap);

/* Values for the log_target parameter android_fork_exec_ext() */
#define LOG_NONE 0
#define LOG_ALOG 1
#define LOG_KLOG 2

int android_fork_execvp_ext(int argc, char* argv[], int *status, bool ignore_int_quit,
int log_target, bool abbreviated);

/* Similar to above, except abbreviated logging is not available, and if logwrap
* is true, logging is to the Android system log, and if false, there is no
* logging.
*/
static inline int android_fork_execvp(int argc, char* argv[], int *status,
bool ignore_int_quit, bool logwrap)
{
return android_fork_execvp_ext(argc, argv, status, ignore_int_quit,
(logwrap ? LOG_ALOG : LOG_NONE), false);
}


__END_DECLS

Expand Down
Loading

0 comments on commit 96e11b5

Please sign in to comment.