Created
August 1, 2011 03:25
-
-
Save faultier/1117523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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