diff --git a/include/log/logger.h b/include/log/logger.h index ff70529fb..b3928a713 100644 --- a/include/log/logger.h +++ b/include/log/logger.h @@ -163,6 +163,8 @@ int android_logger_set_prune_list(struct logger_list *logger_list, #define ANDROID_LOG_RDWR O_RDWR #define ANDROID_LOG_ACCMODE O_ACCMODE #define ANDROID_LOG_NONBLOCK O_NONBLOCK +#define ANDROID_LOG_WRAP 0x40000000 /* Block until buffer about to wrap */ +#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */ #define ANDROID_LOG_PSTORE 0x80000000 struct logger_list *android_logger_list_alloc(int mode, diff --git a/liblog/README b/liblog/README index f29ac045b..df1e68c65 100644 --- a/liblog/README +++ b/liblog/README @@ -116,6 +116,10 @@ DESCRIPTION code, otherwise the android_logger_list_read call will block for new entries. + The ANDROID_LOG_WRAP mode flag to the android_logger_list_alloc_time + signals logd to quiesce the reader until the buffer is about to prune + at the start time then proceed to dumping content. + The ANDROID_LOG_PSTORE mode flag to the android_logger_open is used to switch from the active logs to the persistent logs from before the last reboot. diff --git a/liblog/log_read.c b/liblog/log_read.c index cfc8a7aca..fb8675779 100644 --- a/liblog/log_read.c +++ b/liblog/log_read.c @@ -797,6 +797,14 @@ int android_logger_list_read(struct logger_list *logger_list, } if (logger_list->start.tv_sec || logger_list->start.tv_nsec) { + if (logger_list->mode & ANDROID_LOG_WRAP) { + // ToDo: alternate API to allow timeout to be adjusted. + ret = snprintf(cp, remaining, " timeout=%u", + ANDROID_LOG_WRAP_DEFAULT_TIMEOUT); + ret = min(ret, remaining); + remaining -= ret; + cp += ret; + } ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32, logger_list->start.tv_sec, logger_list->start.tv_nsec); diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index 0c59f2307..059916e78 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -256,13 +257,19 @@ static void show_help(const char *cmd) " -s Set default filter to silent.\n" " Like specifying filterspec '*:S'\n" " -f Log to file. Default is stdout\n" + " --file=\n" " -r Rotate log every kbytes. Requires -f\n" + " --rotate_kbytes=\n" " -n Sets max number of rotated logs to , default 4\n" - " -v Sets the log print format, where is:\n\n" + " --rotate_count=\n" + " -v Sets the log print format, where is:\n" + " --format=\n" " brief color epoch long monotonic printable process raw\n" " tag thread threadtime time usec UTC year zone\n\n" " -D print dividers between each log buffer\n" + " --dividers\n" " -c clear (flush) the entire log and exit\n" + " --clear\n" " -d dump the log and then exit (don't block)\n" " -t print only the most recent lines (implies -d)\n" " -t '