0

When developing on Android, I sometimes miss some asserts in the console (logcat), so I would like to be notified whenever an "Assert" message comes in the logcat, with a "growl" notification for example (I'm on Mac OS X).

I tried this simple command:

adb logcat | grep Assert | growlnotify

but it does not send any notification until I kill the logcat process.

Any ideas?

4

1 回答 1

0

好的,我已经能够使它工作,但是我必须使用外部脚本:

咆哮断言.sh

#!/bin/bash
while read; do
    COUNT=`echo "$REPLY" | grep -c Assert`
    if [ $COUNT -ne 0 ]; then
        echo "$REPLY" | growlnotify -t "Assert on logcat"
    fi
done

然后在控制台中使用这个单行代码启动监控:

while [ 1 ]; do adb logcat -sv time *:E | growl-on-assert.sh; done

无限循环很有用,因此adb可以在设备连接/断开连接时自动重新连接。

欢迎任何改进,例如在同时连接多个设备/模拟器的情况下启动并行监控,或者发送电子邮件而不是咆哮通知。;-)

于 2012-05-22T19:43:44.150 回答