diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index b7f4e17ec..15fc03541 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -82,6 +82,7 @@ static pcrecpp::RE* g_regex; // 0 means "infinite" static size_t g_maxCount; static size_t g_printCount; +static bool g_printItAnyways; // if showHelp is set, newline required in fmt statement to transition to usage __noreturn static void logcat_panic(bool showHelp, const char *fmt, ...) __printflike(2,3); @@ -189,14 +190,16 @@ static void processBuffer(log_device_t* dev, struct log_msg *buf) goto error; } - if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority) && - regexOk(entry)) { - bytesWritten = android_log_printLogLine(g_logformat, g_outFD, &entry); + if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) { + bool match = regexOk(entry); - g_printCount++; + g_printCount += match; + if (match || g_printItAnyways) { + bytesWritten = android_log_printLogLine(g_logformat, g_outFD, &entry); - if (bytesWritten < 0) { - logcat_panic(false, "output error"); + if (bytesWritten < 0) { + logcat_panic(false, "output error"); + } } } @@ -296,6 +299,8 @@ static void show_help(const char *cmd) " --regex where is a regular expression\n" " -m quit after printing lines. This is meant to be\n" " --max-count= paired with --regex, but will work on its own.\n" + " --print paired with --regex and --max-count to let content bypass\n" + " regex filter but still stop at number of matches.\n" " -t print only the most recent lines (implies -d)\n" " -t '