Module: ReactNativeLogCat

Defined in:
lib/react-native-logcat.rb,
lib/react-native-logcat/version.rb

Constant Summary collapse

VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.get_type(str) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/react-native-logcat.rb', line 6

def self.get_type(str)

  if str[0..1] == "D/"
    return str.green
  end

  if str[0..1] == "W/"
    return str.yellow
  end

  return str
end

.startObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/react-native-logcat.rb', line 19

def self.start
  cmd='
  adb logcat *:S ReactNative:V ReactNativeJS:V | {
    while IFS= read -r line
    do
      echo "$line"
    done
  }'

  IO.popen(cmd).each do |line|
    puts self.get_type(line.chomp)
  end
end