Skip to content

Instantly share code, notes, and snippets.

@blaxter
Created July 17, 2012 15:13
Show Gist options
  • Save blaxter/3129996 to your computer and use it in GitHub Desktop.
Save blaxter/3129996 to your computer and use it in GitHub Desktop.
readlog.rb for android adb logcat
#!/usr/bin/ruby
RED = "\033[0;31m"
RESET = "\033[0m"
YELLOW = "\033[0;33m"
C = "\033[0;35m"
trap("INT") { puts; exit! 127 }
def stamp line
puts "#{Time.now.strftime '%H:%M:%S'}: #{line}" if line
end
IO.popen "adb logcat#{" -b radio" if ARGV.length > 2}" do |pipe|
stamp case s = pipe.gets.strip
when /^E\/AndroidRuntime/
if STDOUT.tty?
RED+s+RESET
else
s
end
when /option/i
YELLOW+s+RESET
else
s
end until pipe.eof?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment