Python log entry search utility
On my windows 10 laptop, I ran your program on a dummy log file under the python 
profiler using the command line:

python -m cProfile -s cumulative loggrep.py "speech" \data\test.log 


The dummy log file has about 4.3 Mbytes of text spread across about 100k lines 
comprising 32772 log entries.  The search pattern was "speech", which occured 
444 times.  

This is the ouput of the profiler:

     1322924 function calls (1322872 primitive calls) in 2.006 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   7/1    0.000    0.000    2.006    2.006 {built-in method builtins.exec} 
     1    0.000    0.000    2.006    2.006 loggrep.py:3(&lt;module&gt;)
     1    0.077    0.077    1.997    1.997 loggrep.py:38(process)
100003    0.136    0.000    1.788    0.000 loggrep.py:42(processLine)
 32772    0.013    0.000    1.369    0.000 loggrep.py:60(flush)              &lt;-----
   444    0.014    0.000    1.355    0.003 loggrep.py:67(printBuffer)        &lt;-----
  9722    1.341    0.000    1.341    0.000 {built-in method builtins.print}  &lt;-----
100003    0.061    0.000    0.132    0.000 loggrep.py:71(addToBuffer)
100004    0.042    0.000    0.116    0.000 fileinput.py:248(__next__)
100003    0.028    0.000    0.075    0.000 loggrep.py:80(isEntryHead)
100004    0.060    0.000    0.071    0.000 {method 'readline' of '_io.TextIOWrapper' objects}
195293    0.068    0.000    0.068    0.000 {method 'search' of '_sre.SRE_Pattern' objects}
100003    0.027    0.000    0.062    0.000 loggrep.py:83(isEntryTail)
 95290    0.027    0.000    0.060    0.000 loggrep.py:86(lineMatches)
100010    0.047    0.000    0.047    0.000 {method 'match' of '_sre.SRE_Pattern' objects}


The header shows the program took 2.006 seconds to run. Looking at the 
lines marked with "&lt;-----", we see that flush() was called 32772 times 
and took about 1.369 seconds.  From the code, we know flush() calls 
printbuffer(), which calls print().  The profile says print() was 
called 9722 times taking 1.341 seconds, or about 65% of the total run time.

I changed entryTailPattern to "\|!\s*$".  This let me get rid of the 
.rstrip() on each line so that the lines would keep the '\n' at the end. 
This let me change the print() for loop in printBuffer() to a call to 
sys.stdout.writelines().  This saved about 0.5 seconds over the print() 
for loop.

All the other function calls seem to be in the noise, so i don't see any other 
promising things to try.