How about not forking up to two grep
processes per log line?
tail -Fn +1 "$log_file" | grep -Ei "$search_text|^error\b" | while read line; do
So one long running grep
process shall do preprocessing if you will.
Edit: As noted in the comments, it is safer to add --line-buffered
to the grep
invocation.