Skip to content

Instantly share code, notes, and snippets.

@mxcl
Created June 22, 2010 10:25
Show Gist options
  • Save mxcl/448290 to your computer and use it in GitHub Desktop.
Save mxcl/448290 to your computer and use it in GitHub Desktop.
Makes ADB logcat more readible (for me)
#!/usr/bin/ruby
RED = "\033[0;31m"
RESET = "\033[0m"
YELLOW = "\033[0;33m"
BLUE = "\033[0;35m"
GREY = "\033[0;34m"
trap("INT") { puts; exit! 127 }
def stamp line
puts "#{Time.now.strftime '%H:%M:%S'}: #{line}" if line
end
IO.popen "adb logcat" do |pipe|
stamp case s = pipe.gets.strip
when /^E\/AndroidRuntime/, /E\/TweetDeck/
if STDOUT.tty?
RED+s+RESET
else
s
end
when /^[EWDIV]\/ActivityManager\( *\d+\): .* com\.tweetdeck\.app/
YELLOW+s+RESET
when /^[EWDIV]\/TweetDeck\( *(\d+)\)/
pid = $1
s
when /^D\/dalvikvm\( *(#{pid})\): GC_/
BLUE+s+RESET
when /^[EWDIV]\/.*\( *(#{pid})\):/
GREY+s+RESET
end until pipe.eof?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment