Use start-process
and add a filter to process log output line by line:
(defun line-split (real-filter)
(let ((cum-string-sym (make-symbol "proc-filter-buff"))
(newline (string-to-char "\n"))
(string-indexof (lambda (string char start)
(loop for i from start below (length string)
thereis (and (eq char (aref string i))
i)))))
(set cum-string-sym "")
`(lambda (proc string)
(setf string (concat ,cum-string-sym string))
(let ((start 0) new-start)
(while (setf new-start (funcall ,string-indexof string ,newline start))
(funcall ,real-filter proc (substring string start new-start))
(setf start (1+ new-start)))
(setf ,cum-string-sym (substring string start))))))
(defun my-line(proc line)
(when (string-match "Headset" line)
(print (format "----line: %s" line))))
(defun get-log()
(let ((proc-log nil)(procname "mylogcat")(logbuffer "logbuffer"))
(setq proc-log (start-process procname logbuffer "adb" "logcat"))
(set-process-filter proc-log
(line-split (lambda (proc line) (my-line proc line))))))
(get-log)
This example will capture output of command "adb logcat", then print the lines which contains "Headset" keyword.