Skip to content

Instantly share code, notes, and snippets.

@faultier
Created August 1, 2011 03:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faultier/1117523 to your computer and use it in GitHub Desktop.
Save faultier/1117523 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# coding: utf-8
CMD = "#{ENV['ANDROID_HOME']}/platform-tools/adb logcat -v process"
(TAG,PRIORITY) = (ARGV.first || '*:I').split(':')
Signal.trap(:INT) do
puts "\nさよなライオン"
exit 0
end
IO.popen("#{CMD} -s #{TAG}:#{PRIORITY}", 'r:utf-8') do |log|
while line = log.readline
line.chomp!
line.sub!(/\(#{TAG}\)\z/, '') if TAG != '*'
color = case line
when /\AV/ then 30 # black
when /\AD/ then 33 # yellow
when /\AI/ then 34 # blue
when /\AW/ then 31 # red
when /\AE/ then 41 # on_red
end
STDOUT.puts "\e[#{color}m#{line}\e[0m"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment